Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Error 800A03F2 - Expected Identifier

Status
Not open for further replies.

Pickachu

Programmer
May 17, 2007
7
GB
I have a script below that is giving me the error, i cannot find or see anything wrong with it, can anyone help?
[bigears]Apparently the compilation error is at line 28 col 2, i have indicated the line with a *

Dim objShell, vRunObject
dim filesys, getname, path,

Set objShell = CreateObject("Wscript.Shell")

path = filesys.GetAbsolutePathName("c:\windows\system32\r_server.exe")
vRunObject = "cmd /K " & Chr(34) & "c:\windows\system32\r_server.exe /stop" & Chr(34)
objShell.run vRunObject,0

WaitForProcess ".", "r_server.exe"

Sub WaitForProcess(strComputer, strProcess)
Dim filesys

Dim wmiQuery : wmiQuery = "Select * From Win32_Process Where Name='" _
& strProcess & "'"
Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer _
& "\root\cimv2")
Dim colItems : Set colItems = objWMIService.ExecQuery(wmiQuery)

Dim intProcCount : intProcCount = colItems.Count

Set filesys = CreateObject("Scripting.FileSystemObject")

Do While intProcCount > 0
Set colItems = objWMIService.ExecQuery(wmiQuery)
* intProcCount = colItems.Count
Loop

If filesys.FileExists(path) Then
filesys.DeleteFile path
End If

End Sub
 
Anyway, I'd change this:
vRunObject = "cmd /K " & Chr(34) & "c:\windows\system32\r_server.exe /stop" & Chr(34)
with this:
vRunObject = "cmd /K " & Chr(34) & "c:\windows\system32\r_server.exe" & Chr(34) & " /stop"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV, i will change it but according to the error i get the problem lies with this bit of code;

Do While intProcCount > 0
Set colItems = objWMIService.ExecQuery(wmiQuery)
intProcCount = colItems.Count
Loop
 
I don't see where the sub should be giving you an error. I just tried it with having it monitor notepad.exe. My suggestion would be to leave the sub alone and remove the things you added to it and have those accomplished outside.

i.e. simply use

Code:
Sub WaitForProcess(strComputer, strProcess)
	Dim wmiQuery : wmiQuery = "Select * From Win32_Process Where Name='" _
							  & strProcess & "'"
	Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer _
											& "\root\cimv2")
	Dim colItems : Set colItems = objWMIService.ExecQuery(wmiQuery)
	Dim intProcCount : intProcCount = colItems.Count
	
	Do While intProcCount > 0
		Set colItems = objWMIService.ExecQuery(wmiQuery)
		intProcCount = colItems.Count
	Loop
End Sub

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Thanks for your help dm4ever, this worked atreat i was obviously having a bad day!

[2thumbsup][yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top