在 Windows 8 之前的 Windows 版本上,我的安装程序使用与此类似的 VB 脚本来启动任务管理器:
' StartProcessLocal.vbs
' Free example VBScript to start a process (not interactive)
' Author Guy Thomas
' Version 1.8 - December 2010
' -------------------------------------------------------'
Option Explicit
Dim objWMIService, objProcess, objCalc
Dim strShell, objProgram, strComputer, strExe
strComputer = "."
strExe = "Taskmgr.exe"
' Connect to WMI
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe
'Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)
WScript.echo "Created: " & strExe & " on " & strComputer
WSCript.Quit
这不会在 Windows 8.1 上启动任务管理器。
Taskmgr.exe 位于 System32 目录中,当我双击它时,它启动正常。它从命令提示符开始正常:>Taskmgr.exe
在上面的示例中,如果您将 Taskmgr.exe 更改为 Calc.exe,它将启动计算器。 Calc.exe 也在 System32 文件夹中。
为什么上面的脚本没有启动任务管理器?
最佳答案
你尝试过这样启动吗?
Option Explicit
Dim Application
Application = "%windir%\system32\Taskmgr.exe"
Call RunThis(Application)
'*********************************************************************************
Sub RunThis(Application)
Dim Ws,Result
Set Ws = CreateObject("WScript.Shell")
Result = Ws.Run(DblQuote(Application),1,False)
End Sub
'*********************************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'*********************************************************************************
关于vbscript - 在 Windows 8.1 上从 VBScript 启动任务管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33257101/