I run the "run as" part with a encrypted vbs code.
not 100 % success.
the window have to be "active" otherwise the script will fail, and the password is pasted to the active window.
kixcode code:
IF $OS = "WinNT4"
? "Do Noting procced"
else
Run '%comspec% /c wscript x:\script\vbs\hfnetchk.vbe'
sleep 2
endif
hfnetchk.vbs
code:
Dim vbOK: vbOK = 1
Dim vbCancel: vbCancel=2
Dim Wshell, ret, msg01, msghdr01, strUser, strPass
Dim CompName: CompName="Blank"
Set WshNetwork = WScript.CreateObject("WScript.Network")
CompName = WshNetworK.ComputerName
Set WshNetwork = nothing
function execute()
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\system32\runas.exe /user:" & strUser & " " & Chr(34)& "\\whatand where to start" & CompName & ".bat" & Chr(34)
Wscript.Sleep 100
WshShell.AppActivate "runas"
wScript.Sleep 100
WshShell.SendKeys strPass
wScript.Sleep 100
WshShell.SendKeys "~"
Wscript.Quit
end function
'** Start Encode **
strUser="domain\user"
strPass="password"
execute()
\erik