1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Option Explicit
'Run as Admin
If Not WScript.Arguments.Named.Exists("elevate") Then
CreateObject("Shell.Application").ShellExecute DblQuote(WScript.FullName) _
, DblQuote(WScript.ScriptFullName) & " /elevate", "", "runas", 1
WScript.Quit
End If
Const SW_HIDE = 0
Dim ws,Command,LogFile,return
LogFile = Left(Wscript.ScriptFullName,InstrRev(Wscript.ScriptFullName, ".")) & "txt"
set ws = createobject("wscript.shell")
Command = "cmd /c NET SESSION > "& LogFile &" 2>&1"
msgbox Command
return = ws.run(command,SW_HIDE,True)
ws.run DblQuote(LogFile)
'**************************************
Function DblQuote(Str)
DblQuote = chr(34) & Str & chr(34)
End function
'************************************** |
Partager