简体   繁体   中英

Taskkill Exit code : 255

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM