• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

wshell.run

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
Chuckbuchan
Asked:
Chuckbuchan
  • 7
  • 3
  • 3
  • +1
3 Solutions
 
merowingerCommented:
- 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
 
TimCotteeCommented:
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
 
ChuckbuchanAuthor Commented:
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
Technology Partners: 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!

 
merowingerCommented:
try

wshell.run ("C:\Program Files\Internet explorer\iexplore.exe")
0
 
TimCotteeCommented:
Chuckbuchan,

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

Tim
0
 
AlexFMCommented:
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
 
ChuckbuchanAuthor Commented:
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
 
ChuckbuchanAuthor Commented:
To AlexFM :
can you explain to me your approach in DOS using this simple path?
C:\Program Files\Internet explorer\iexplore.exe")
0
 
ChuckbuchanAuthor Commented:
did you try this in your computers guys?


set wshell=createobject("wscript.shell")
wshell.run "C:\Program Files\Internet explorer\iexplore.exe"
0
 
merowingerCommented:
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
 
ChuckbuchanAuthor Commented:
this didn't work either. 3 x " in each side

set wshell=createobject("wscript.shell")
wshell.run """C:\Program Files\Internet Explorer.exe"""
0
 
ChuckbuchanAuthor Commented:
sorry
set wshell=createobject("wscript.shell")
wshell.run """C:\Program Files\Internet Explorer\iexplore.exe"""
0
 
ChuckbuchanAuthor Commented:
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
 
TimCotteeCommented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 7
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now