I am trying to launch a HTA, via VBS script with my domain account (and have it prompt me for
The script and hta will be in the same directory on a flash drive, so the code has to point to the current directory of the script.
The code below currently launches the hta from the scripts directory, but I am not able to pass a username (eg domain/username) to launch the hta as another user
Set objShell = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetParentFolderName (WScript.ScriptFullName)
If FSO.FileExists(strPath & "\main.HTA") Then
objShell.ShellExecute "mshta", Chr(34) & strPath & "\main.HTA" & Chr(34), "", "runas", 1
Else
MsgBox "Error - HTA was not found"
End If
How can I save the username (and/or password) as variables and pass it to the runas part of the script to launch the HTA with different user credentials?
EDIT:
Here is the Batch file equivalent of what I am trying to do:
runas /user:domain\username "c:\windows\system32\mshta.exe \"\main.hta\
Current username you can get with the code below, passwords can’t be got by any means I think.