VB script problem (Kill Process script)
Moderators: Dorian (MJT support), JRL
VB script problem (Kill Process script)
Since the update to 7.4 I'm getting the following error :-2147023828 Line 9, Column 2 when using this VB script
let>APP_TITLE=
VBSTART
Sub killProcess(pgm)
set wmi = getobject("winmgmts:")
sQuery = "select * from win32_process " & "where name='" & pgm & "'"
set processes = wmi.execquery(sQuery)
for each process in processes
process.terminate
next
End Sub
Sub StopService(sServiceName)
strComputer = "."
Set wbemServices = GetObject("winmgmts:\\" & strComputer)
sWQL = "Select state from Win32_Service " & "Where displayname='" & sServiceName & "'"
Set oResults = wbemServices.ExecQuery(sWQL)
For Each oService In oResults
If Trim(LCase(oService.State)) = LCase("Running") Then
oService.StopService
End If
Next
End Sub
VBEND
VBRun>KillProcess,IEXPLORE.exe
I didn't have the problem with 7.3 or the beta versions. Any help on this is appreciated.
let>APP_TITLE=
VBSTART
Sub killProcess(pgm)
set wmi = getobject("winmgmts:")
sQuery = "select * from win32_process " & "where name='" & pgm & "'"
set processes = wmi.execquery(sQuery)
for each process in processes
process.terminate
next
End Sub
Sub StopService(sServiceName)
strComputer = "."
Set wbemServices = GetObject("winmgmts:\\" & strComputer)
sWQL = "Select state from Win32_Service " & "Where displayname='" & sServiceName & "'"
Set oResults = wbemServices.ExecQuery(sWQL)
For Each oService In oResults
If Trim(LCase(oService.State)) = LCase("Running") Then
oService.StopService
End If
Next
End Sub
VBEND
VBRun>KillProcess,IEXPLORE.exe
I didn't have the problem with 7.3 or the beta versions. Any help on this is appreciated.
The original script is from this topic http://www.mjtnet.com/forum/viewtopic.php?p=7160#7160
When running the original script I get the same error (line 3 in this case) plus one on line 13 column 3.
When running the original script I get the same error (line 3 in this case) plus one on line 13 column 3.
That script works fine for me without any problem. It's pure VBScript so can't have anything to do with 7.4.
MJT Net Support
[email protected]
[email protected]
Hum, I have both 7.3 and 7.4 installed and I'm getting errors with both versions. I even had someone else try it and he is getting errors, too.
Maybe some else can try the script and report back if it's working fine or giving error?
I'm using that script for a program of mine but now due to the error I can't update it.
Thanks
Maybe some else can try the script and report back if it's working fine or giving error?
I'm using that script for a program of mine but now due to the error I can't update it.
Thanks
I too have tried this and I get error after error!
I am using 7.4 beta 004
I get these errors:
" set wmi = getobject("winmgmts:") - window not found "
":-2147024894 Line 7, Column 2"
The line is: for each process in processes
Which looks like a comment so I removed it and got more errors!
So then I noticed in MS you dont need any of the > after the commands!
Maybe that is messing somethings up?
I am using 7.4 beta 004
I get these errors:
" set wmi = getobject("winmgmts:") - window not found "
":-2147024894 Line 7, Column 2"
The line is: for each process in processes
Which looks like a comment so I removed it and got more errors!
So then I noticed in MS you dont need any of the > after the commands!
Maybe that is messing somethings up?
Bare with me here.
I just noticed something, the line were I get the error starts with set.
I just wrote a little test script and noticed when writing a line like this set Notepad* it works without having to use > but not only that it works with other commands, too.
Try running the script bellow
wwo Notepad*
set Notepad*
mvw Notepad*,0,0
wpc 16777215,13,70,0
goto 2
label 2
Since MS is reading set and set> as a program command could it be confusing the word set in the VB script?
I hope this makes sense
I just noticed something, the line were I get the error starts with set.
I just wrote a little test script and noticed when writing a line like this set Notepad* it works without having to use > but not only that it works with other commands, too.
Try running the script bellow
wwo Notepad*
set Notepad*
mvw Notepad*,0,0
wpc 16777215,13,70,0
goto 2
label 2
Since MS is reading set and set> as a program command could it be confusing the word set in the VB script?
I hope this makes sense
That will happen if you miss out VBSTART/VBEND. Without the VBSTART - VBEND block Macro Scheduler will think the code is MacroScript so Set will be seen as SetFocus. Ensure you have VBSTART and VBEND arround the VBScript and it will process it as VCBscript. Maybe you have an invisible character after or before VBSTART and/or VBEND. Do Edit/Remove Trailing Spaces and then try it. The script works fine for me.
MJT Net Support
[email protected]
[email protected]