Cannot do this with a VBS alone.
You would need to create a batch file to pass this %APPDATA%
environment variable into the script as Argument, then modify the VBS script to process this argument(s).
Sample below:
UPDATE:
If you do not mind people being able to open the batch file and know the password of the user account you intend to Run As, get psexec.exe from MS with the updated batch file contents (assuming psexec.exe stored in C:\SysInt\
):
VBS File
Dim sTxt
sTxt = WScript.Arguments.Count & " arguments passed into vbs:"
sTxt = sTxt & JoinArgs
wscript.echo sTxt
Function JoinArgs()
Dim sTmp
sTmp = ""
For Each oArg In Wscript.Arguments
sTmp = sTmp & vbCrLf & oArg
Next
JoinArgs = sTmp
End Function
Batch File (UPDATED)
@echo off
C:\SysInt\psexec.exe -u %computername%\administrator -p AccountPassword -e wscript.exe "c:\debug\vbs\test.vbs" %appdata%