Saturday, January 22, 2011

Run-As Script

set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.run "runas /user:Domain\Username %comspec%" 'Open command prompt

WScript.Sleep 1000

WshShell.SendKeys "password" 'send password

WshShell.SendKeys "{ENTER}"

WScript.Sleep 1000 'Open AD Users & Computers

WshShell.SendKeys Chr(34) + "C:\Program Files\Exchsrvr\bin\users and computers.msc" + Chr(34)

WshShell.SendKeys "{ENTER}"

WshShell.SendKeys "exit" 'Close command prompt

WshShell.SendKeys "{ENTER}"

WScript.Sleep 1000 set

wshshell = nothing

No comments:

Post a Comment