VB script problem (Kill Process script)

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

VB script problem (Kill Process script)

Post by Rain » Sat Sep 10, 2005 2:58 pm

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.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sat Sep 10, 2005 3:16 pm

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.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sat Sep 10, 2005 4:41 pm

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]

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sat Sep 10, 2005 10:14 pm

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

jyk
Newbie
Posts: 1
Joined: Sat Sep 10, 2005 10:32 pm

Post by jyk » Sat Sep 10, 2005 10:39 pm

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?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sat Sep 10, 2005 10:43 pm

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 :?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sun Sep 11, 2005 1:51 pm

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]

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Sep 12, 2005 11:01 am

I run the script like it's posted in my first post and yes I removed the trailing spaces. I'm starting to think something has changed on my system because an exe that I compiled way before the update is giving me the same exact error.
Thanks for your time.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue Sep 13, 2005 11:22 pm

I finally reformatted my system and that fixed the problem for me. I'm not really sure what was causing the errors :?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts