【发布时间】:2016-04-22 09:40:56
【问题描述】:
我正在调用另一个 VBScript 以以管理员身份运行。 以下是 Invoker VBScript 代码
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "cscript", "C:\Temp\XYZ.vbs", "", "runas", 0
Wscript.Quit 1
下面是XYZ.vbs代码
On Error Resume Next
Dim strComputerRole, strDomain, strComputer, strText, strText2
Dim arrServiceList, strNextLine
Dim objFile, objFile2, strFile, strSysDrive, strTempDir, strSQLcommand
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = wscript.createObject("Wscript.Shell")
Set colProcEnvVars = objShell.Environment("Process")
Set colSystemEnvVars = objShell.Environment("System")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
strSysDrive = colProcEnvVars("systemdrive")
strTempDir = colProcEnvVars("SY0")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
If strSysDrive = "" Then
strSysDrive = "C:"
End If
If strTempDir = "" Then
strTempDir = strSysDrive & "\Temp"
End If
If Not objFSO.FolderExists(strTempDir) Then
objFSO.CreateFolder(strTempDir)
End If
strFile = strSysDrive & "\temp\XYZ.txt"
strSQLcommand="osql -o "& strFile & " -d HOST -E -Q ""************Select Query******** """
Set objExecObject = objShell.Exec(strSQLcommand)
【问题讨论】:
标签: vbscript cmd shellexecute wsh