[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

vbs file error

Posted on 2011-09-22
2
Medium Priority
?
384 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
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

830 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