Newsgroups: microsoft.public.scripting.vbscript
From: "Richard Mueller [MVP]" <rlmueller-nos...@ameritech.nospam.net>
Date: Thu, 5 Nov 2009 17:20:01 -0600
Local: Thurs, Nov 5 2009 11:20 pm
Subject: Re: Script
news:OORp6rmXKHA.220@TK2MSFTNGP02.phx.gbl...
> Why does this script work: Check out the LocalAppData environment variable. Also, once you retrieve the > ' 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") value of the environment variable and assign it to a variable, use the variable. For example, try: ======== Dim LocalAppData, WshShell, objFSO Set WshShell = CreateObject("Wscript.Shell") LocalAppData = WshShell.ExpandEnvironmentStrings("%LocalAppData%") objFSO.DeleteFile(LocalAppData & "\test.vbs") Wscript.Echo LocalAppData & "\test.vbs" -- 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.
| ||||||||||||||