VBRunas
Ermöglicht unter W2K/XP das Ausführen von Befehlen/Scripten/Programmen mit Adminberechtigung im Userkontext.
Die Variablen "sUser" und "sPass" müssen individuell angepasst werden.
Tip:
Verschlüsseln mit Windows Script Encoder
'USAGE: cscript|wscript VBRUNAS.VBS Command
On Error Resume Nextdim WshShell,oArgs,FSO
set oArgs=wscript.Arguments
if oArgs.Count <1 then wscript.echo VBCRLF & "! Usage Error !" & VBCRLF End if
sUser="%computername%\administrator"sPass="passwort" & VBCRLFsCmd=oArgs(0)
set WshShell = CreateObject("WScript.Shell")set WshEnv = WshShell.Environment("Process")WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"set FSO = CreateObject("Scripting.FileSystemObject")
if FSO.FileExists(winpath) then 'wscript.echo winpath & " " & "verified"else wscript.echo "!! ERROR !!" & VBCRLF & "Can't find or verify " & winpath &"." & VBCRLF & "You must be running Windows 2000 for this script to work." set WshShell=Nothing set WshEnv=Nothing set oArgs=Nothing set FSO=Nothing wscript.quitend if
rc=WshShell.Run("runas /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)Wscript.Sleep 30 'need to give time for window to open.WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password toWshShell.SendKeys sPass 'send the password to the waiting window.
set WshShell=Nothingset oArgs=Nothingset WshEnv=Nothingset FSO=Nothing
wscript.quit