#1 16 Oct 2013 12:52

diasje
Member
Registered: 09 Oct 2013
Posts: 15

(TIP) Automate RunAs Password Entry

Enables automated password entry for the RunAs command.

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run "runas /user:domain\user %comspec%" 'Open command prompt 
WScript.Sleep 1000
WshShell.SendKeys "password" 'send password   
WshShell.SendKeys "{ENTER}"   
WScript.Sleep 1000
'Open IE
WshShell.SendKeys Chr(34) + "C:\PROGRAM FILES\INTERNET EXPLORER\IEXPLORE.EXE" + Chr(34)
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "exit"  'Close command prompt
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "http://www.microsoft.com" 'Send internet page to open to IE
WshShell.SendKeys "{ENTER}"
set wshshell = nothing

Offline

Board footer

Powered by FluxBB