PDA

View Full Version : VBScript | Help with Env Variables


Aukiman
18th February 2009, 09:54 AM
here's one for you vbscript guru's

currently working on a GPO solution via Active Directory for some WSUS client agent issues we are experiencing on XP, best form is to use vbscript to create a machine startup script to get around issues with end user credentials and access.

However I have run into problems, this patch needs to be run across a mixed XP SOE environment where the location of user profile paths can differ between drives so we need to create a solution using environment variables especially for %ALLUSERSPROFILE%

This is where I have encountered difficulties and my vbscript isn't up to the task.

for eg. the basic command in DOS would be simply del "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr0.dat" /S /Q

I attempted to invoke a vbscript call to the shell via:

Set WshObj = Wscript.CreateObject("WScript.Shell")
WshObj.Run "del "%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Downloader\qmgr0.dat" /S /Q", 1, true
set WshObj = Nothing

however vbscript hates the % variable

Anyone know much about working with environmental variables in this manner?

Magrath
18th February 2009, 11:06 AM
This should work :)

Set WshObj = Wscript.CreateObject("WScript.Shell")
strALLUSERS = WshOBJ.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")
WshObj.Run "del " & strALLUSERS & "\Application\Data\Microsoft\Network\Downloader\qmg r0.dat" /S /Q", 1, true
set WshObj = Nothing


here's one for you vbscript guru's

currently working on a GPO solution via Active Directory for some WSUS client agent issues we are experiencing on XP, best form is to use vbscript to create a machine startup script to get around issues with end user credentials and access.

However I have run into problems, this patch needs to be run across a mixed XP SOE environment where the location of user profile paths can differ between drives so we need to create a solution using environment variables especially for %ALLUSERSPROFILE%

This is where I have encountered difficulties and my vbscript isn't up to the task.

for eg. the basic command in DOS would be simply del "%ALLUSERSPROFILE%Application DataMicrosoftNetworkDownloaderqmgr0.dat" /S /Q

I attempted to invoke a vbscript call to the shell via:

Set WshObj = Wscript.CreateObject("WScript.Shell")
WshObj.Run "del "%ALLUSERSPROFILE%Application DataMicrosoftNetworkDownloaderqmgr0.dat" /S /Q", 1, true
set WshObj = Nothing

however vbscript hates the % variable

Anyone know much about working with environmental variables in this manner?