Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Fri, 6 Nov 2009 00:10:52 +0100
Local: Thurs, Nov 5 2009 11:10 pm
Subject: Re: Script
news:OORp6rmXKHA.220@TK2MSFTNGP02.phx.gbl...
> Why does this script work: If you replace the line > ' Description: Demonstration script that uses the FileSystemObject to > Set WSHShell = WScript.CreateObject("WScript.Shell") > objFSO.DeleteFile("F:\Users\TestUser\AppData\Local\test.vbs") > And this script does not work: > ' Description: Demonstration script that uses the FileSystemObject to > Dim Windir > Set WSHShell = WScript.CreateObject("WScript.Shell") > objFSO.DeleteFile("%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\tes t.vbs") objFSO.DeleteFile("%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\tes t.vbs") with this line wscript.echo "%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\test.vbs" then you will see immediately why it cannot possibly work. Neither objFSO.DeleteFile nor wscript.echo can resolve environmental variables such as %SystemRoot%. How about something like this? objFSO.DeleteFile(Local & "\test.vbs") I also urge you to open a Command Prompt (click Start / Run / cmd {OK} and echo %SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local% I took it right from your own code. As you see, it produces nonsense. You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||