Solved

vbs file error

Posted on 2011-09-22
2
375 Views
Last Modified: 2012-05-12
I am trying to run a vbs file with the attached code.

However i get the error "The system cannot find the file specified"

on this line

objShell.Run "C:\program files\xarios\phone manager\phonemanager.exe"

The path does exist, i can go to the folder in command prompt and if i type in phonemanager.exe it opens.
sComputerName = "."
sTask = "Phonemanager.exe"
SET oWMI = GETOBJECT("winmgmts:" & "{impersonationLevel=impersonate}!\\" & sComputerName & "\root\cimv2")
SET cTask = oWMI.ExecQuery ("Select * from Win32_Process Where Name = '" & sTask & "'")
FOR EACH oTask in cTask
oTask.Terminate()
NEXT

msgbox "Stopping Service"

'Stop Service
strServiceName = "FwcAgent"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices
    objService.StopService()
Next

msgbox "Starting Xarios"


'strProgramPath = "C:\program files\xarios\phone manager\PhoneManager.exe"

set objShell = createobject("Wscript.Shell")

objShell.Run "C:\program files\xarios\phone manager\phonemanager.exe"

msgbox "paused"

wscript.sleep 3000

msgbox "Resumed"


'Start Service
strServiceName = "FwcAgent"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices
    objService.StartService()
Next

Open in new window

0
Comment
Question by:CaptainGiblets
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 36579792
Hi, try it like this:
objShell.Run """C:\program files\xarios\phone manager\phonemanager.exe"""

or this
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPhoneManager = objFSO.GetFile("C:\program files\xarios\phone manager\phonemanager.exe").ShortPath
objShell.Run strPhoneManager

Regards,

Rob.
0
 
LVL 6

Expert Comment

by:jorgedeoliveiraborges
ID: 36583842
There is a mistake in the use of quotes (").

objShell.Run " ""C:\program files\xarios\phone manager\phonemanager.exe"" "
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question