> "PaulM" <N...@NONO.COM> wrote in message
> news:OORp6rmXKHA.220@TK2MSFTNGP02.phx.gbl...
>> Why does this script work:
>> ' Description: Demonstration script that uses the FileSystemObject to
>> delete a file. Local computer
>> ' For Vista
>> Set WSHShell = WScript.CreateObject("WScript.Shell")
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> objFSO.DeleteFile("F:\Users\TestUser\AppData\Local\test.vbs")
>> And this script does not work:
>> ' Description: Demonstration script that uses the FileSystemObject to
>> delete a file. Local computer
>> ' For Vista
>> Dim Windir
>> Dim Users
>> Dim UserProfile
>> Dim AppData
>> Dim Local
>> Set WSHShell = WScript.CreateObject("WScript.Shell")
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> Windir = WshShell.ExpandEnvironmentStrings("%SystemRoot%")
>> Users = WshShell.ExpandEnvironmentStrings("%Users%")
>> UserProfile = WshShell.ExpandEnvironmentStrings("%UserProfile%")
>> AppData = WshShell.ExpandEnvironmentStrings("%AppData%")
>> Local = WshShell.ExpandEnvironmentStrings("%Local%")
>> objFSO.DeleteFile("%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\tes t.vbs")
> Check out the LocalAppData environment variable. Also, once you retrieve
> the 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")
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> LocalAppData = WshShell.ExpandEnvironmentStrings("%LocalAppData%")
> objFSO.DeleteFile(LocalAppData & "\test.vbs")
> =========
> You can troubleshoot with statements similar to:
> Wscript.Echo LocalAppData & "\test.vbs"
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --