Solved

vbs file error

Posted on 2011-09-22
2
367 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
Comment Utility
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
Comment Utility
There is a mistake in the use of quotes (").

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now