?
Solved

wshell.run

Posted on 2005-04-05
14
Medium Priority
?
422 Views
Last Modified: 2013-11-13
I am trying to run a program through a vbscript using the wshell.run

set wshell=createobject("wscript.shell")
wshell.run "C:\Program Files\Intuit\Track-It! 6.5\Track-It! Server - Professional Edition\audit32.exe"

each time I run the script it gives me error: The system cannot find the file specified


line 2
char 1

ANy idea?

thanks

0
Comment
Question by:Chuckbuchan
[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
  • 7
  • 3
  • 3
  • +1
14 Comments
 
LVL 31

Expert Comment

by:merowinger
ID: 13706996
- check out that the path is matching

- path is right...then try it with ()
wshell.run ("C:\Program Files\Intuit\Track-It! 6.5\Track-It! Server - Professional Edition\audit32.exe")

- if this does not work try it with an easier path not with --> ! <--


good luck!!!
mero
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 400 total points
ID: 13707015
Hi Chuckbuchan,

wshell.run """C:\Program Files\Intuit\Track-It! 6.5\Track-It! Server - Professional Edition\audit32.exe"""

It is because you have spaces and other odd characters in the path to the executable, adding "" (which translates as a single " when passed to the shell) should allow it to work as you would hope it would.

Tim Cottee
0
 

Author Comment

by:Chuckbuchan
ID: 13707325
I tried this path which doesn't have odd characters and it still gives me the same error.


set wshell=createobject("wscript.shell")
wshell.run "C:\Program Files\Internet explorer\iexplore.exe"


0
Independent Software Vendors: 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!

 
LVL 31

Expert Comment

by:merowinger
ID: 13707391
try

wshell.run ("C:\Program Files\Internet explorer\iexplore.exe")
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 13707394
Chuckbuchan,

Yes, but you still haven't added the extra " characters!

Tim
0
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 200 total points
ID: 13707398
Replace path with characters with DOS-style path. For example, Program Files is written as PROGRA~1.
I don't know how directory Track-It! Server - Professional Edition is converted to DOS path. Open DOS window in C:\Program Files\Intuit and type dir /x to see this.
0
 

Author Comment

by:Chuckbuchan
ID: 13707874
this didn't work
wshell.run ("C:\Program Files\Internet explorer\iexplore.exe")


this didn't work either
wshell.run  ""C:\Program Files\Internet Explorer.exe""
0
 

Author Comment

by:Chuckbuchan
ID: 13707894
To AlexFM :
can you explain to me your approach in DOS using this simple path?
C:\Program Files\Internet explorer\iexplore.exe")
0
 

Author Comment

by:Chuckbuchan
ID: 13707908
did you try this in your computers guys?


set wshell=createobject("wscript.shell")
wshell.run "C:\Program Files\Internet explorer\iexplore.exe"
0
 
LVL 31

Assisted Solution

by:merowinger
merowinger earned 400 total points
ID: 13707916
you should read the post from TimCottee clearly!!!!


3 x "  on each side

"""C:\Program Files\Intuit\Track-It! 6.5\Track-It! Server - Professional Edition\audit32.exe"""
0
 

Author Comment

by:Chuckbuchan
ID: 13707933
this didn't work either. 3 x " in each side

set wshell=createobject("wscript.shell")
wshell.run """C:\Program Files\Internet Explorer.exe"""
0
 

Author Comment

by:Chuckbuchan
ID: 13707943
sorry
set wshell=createobject("wscript.shell")
wshell.run """C:\Program Files\Internet Explorer\iexplore.exe"""
0
 

Author Comment

by:Chuckbuchan
ID: 13707983
Ah sorry :
the 03 x " worked fine this time
I tried it on :
set wshell=createobject("wscript.shell")
wshell.run """C:\Program Files\Internet Explorer\iexplore.exe"""

I need to try it this way later

set wshell=createobject("wscript.shell")
wshell.run """C:\Program Files\Intuit\Track-It! 6.5\Track-It! Server - Professional Edition\audit32.exe"""

by the way can you explain to me why such many ", even with a simple path like:
C:\Program Files\Internet Explorer\iexplore.exe

0
 
LVL 43

Expert Comment

by:TimCottee
ID: 13708082
Chuckbuchan,

This is perfectly standard windows behaviour, any path or filename that has spaces in (or other non alpha characters) must be enclosed in " characters, all the """ at each end does is exactly that.

VB and VBScript interpret two " characters together as meaning 'use one really', in other words when you put """Hello""" into a string variable and then display it, you will only see "Hello" as the result. As this is kind of what you are doing here, it is equivalent to typing

"c:\program files\intuit..........\audit32.exe" at a command prompt. The """ becomes a single " when it is processed.

AlexFM's approach is to use the short path as opposed to the long path form with spaces etc that windows automatically assigns when you create an object with a long path. Every file/folder has a short form representation which is usually the first 6 characters of the file/folder name followed by ~ and a number. This can vary to some extent and guessing is not always reliable. This approach will work but requires you to work out the short representation of each folder in the path hierarchy and the file name itself.

If it isn't working for you then perhaps the files do not exist where you think they do.



Tim
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Simple Linear Regression
Introduction to Processes
Suggested Courses

752 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