Solved

vbs file error

Posted on 2011-09-22
2
369 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 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 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