|
这种?
- If WScript.Arguments.Count <> 1 Then WScript.Quit 1
- RunAsAdmin
- Main
- Sub RunAsAdmin()
- Set Shell = CreateObject("WScript.Shell")
- Set Env = Shell.Environment("VOLATILE")
- If Shell.Run("%ComSpec% /C""NET FILE""", 0, True) <> 0 Then
- Env("CurrentDirectory") = Shell.CurrentDirectory
- ArgsList =""
- For i = 1 To WScript.Arguments.Count
- ArgsList = ArgsList &"""""" & WScript.Arguments(i - 1)
- Next
- CreateObject("Shell.Application").ShellExecute WScript.FullName,"""" & WScript.ScriptFullName & ArgsList &"""", ,"runas", 5
- WScript.Sleep 100
- Env.Remove("CurrentDirectory")
- WScript.Quit
- End If
- If Env("CurrentDirectory") <>"" Then Shell.CurrentDirectory = Env("CurrentDirectory")
- End Sub
- Sub Main()
- '你的代码放在这!
- End Sub
复制代码 |
|