Taskkill Exit code : 255

六眼飞鱼酱① 提交于 2019-12-23 01:54:56

问题


I'm trying to distribute software through SCCM 2012; running a simple command in a vbs, ends with the result code 255.

Example:

WshShell.run ("TASKKILL /F /IM """ & processname & """ /T", 0, True)

After returning 255, the script stops and doesn't install the software.

Someone had this problem? What does the code 255 mean?

Thanks.


回答1:


Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_Process")

For Each objItem in colItems
    'msgbox objItem.ProcessID & " " & objItem.CommandLine
    If objItem.name = "Calculator.exe" then objItem.terminate
Next

Is how to terminate programs in vbscript.




回答2:


this is the correct way

processname="my process name .exe"    
WshShell.run "TASKKILL /F /IM """ & processname & """ /T", 0, False
wscript.sleep 300

First don't use parentheses when you calling a Sub .Use parentheses when you assign that line to Variable or when you use word call.

var = WshShell.run ("TASKKILL /F /IM """ & processname & """ /T", 0, False)

Or

Call WshShell.run ("TASKKILL /F /IM """ & processname & """ /T", 0, False)

Second i prefer to use False instead of True to avoid relay in the script to wait until finish execute the command line instead of that i like use wscript.sleep 300 if you will execute other line after this line of code .don't relay automatic stuff.



来源:https://stackoverflow.com/questions/35298200/taskkill-exit-code-255

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!