hi steve:
thanks - but that did not work - when it runs, it never even gets to the directory change, doesnt seem to like the esacpes.
dave
Main Topics
Browse All TopicsHi:
I am having no luck passing a variable that is defined in vbscript into a cmd line to kick off a program. The program is looking for a start line like this:
>myprog.exe :\files
This will open the program and it will point to the files directory to display photos in that folder when it opens.
I want to take a variable that contains a directory path already defined in a prior part of the script. The script starts one program and it results in the var objpath set with the desired directory path. Then I want to kick off the second program above passing the objpath string as its argument. The first program must startup in its own directory, thats why I am doing the reset of the directory to reposition and start the second.
Here's my current code which starts the second program but the objpath var is not seen.
Dim objShell
Set objShell = CreateObject("WScript.Shel
strfred = objpath
wscript.echo strfred
objShell.Run "%comspec% /k cd\ " & _
"& cd\program files" & _
"& cd breezesys\breezebrowserpro
"& set strfred" & _
"& secondprogram.exe strfred"
thanks for any help!!!
dave
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You know I simply can't get the script engine to consume this simple processing. It keeps coming back with can't "Could not create object named "WScript.shell" when I run it like so:
wscript //NoLogo temp.vbs
or
cscript //NoLogo temp.vbs
I was poking around and I found logic that supports the syntax of your original posting:
http://msdn.microsoft.com/
You could try placing your code in a temporary batch file and executing the batch file via the Run statement.
Steve:
I had thought of the bat file too, but I am convinced this should work. (simple mind, easy to convince!) In the mean time I will follow the link you provided. Thanks!!!
So I tried a different approach:
Set objShell = CreateObject("Wscript.Shel
wscript.Echo strfred
strCommand = "cd\ C:\program files\breezesys\breezebrow
wscript.Echo strCommand
objShell.Run strCommand
strCommand = "breezebrowser.exe " & strfred
wscript.Echo strCommand
objShell.Run strCommand
When it hits eaither Run it errors out saying it cant find the program (!). Below I've pasted the front part of the script, maybe I am doing something up there that is mucking things up? Cause if I rem out the Run commands and watch the echo outputs, everything looks really good.
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Set objShell = CreateObject("Shell.Applic
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a folder:", OPTIONS, "C:\010101_NJQHA")
strfred = objpath
If objFolder Is Nothing Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
Set objShell = CreateObject("Wscript.Shel
dim strfred
strfred = objpath
strCommand = "downloader.exe"
strCommand = strCommand & " /d " & chr(34) & strfred & chr(34)
objShell.run strCommand
wscript.echo "OK to continue?"
confused.
d
Try this: You have given " after strfred whereas it should be before the variable. The variables should not be in the quotes.
Dim objShell
Set objShell = CreateObject("WScript.Shel
strfred = objpath
wscript.echo strfred
objShell.Run "%comspec% /k cd\ " & _
"& cd\program files" & _
"& cd breezesys\breezebrowserpro
"& set strfred" & _
"& secondprogram.exe " & strfred
Imran:
Thank you for taking the time to answer....I was able to get this working by using the following:
Set WshShell = wscript.CreateObject("WScr
strCommand = """c:\program files\breezesys\breezebrow
'wscript.echo strCommand
WshShell.Run strCommand
Quotes sure are fun!
dave
Business Accounts
Answer for Membership
by: SteveGTRPosted on 2006-03-02 at 11:53:46ID: 16088126
Try escaping the & like so:
" & _
objShell.Run "%comspec% /k cd\ " & _
"^& cd\program files" & _
"^& cd breezesys\breezebrowserpro
"^& set strfred" & _
"^& secondprogram.exe strfred"
Good Luck,
Steve