Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with .RUN, doesn't execute program 1

Status
Not open for further replies.

kimbly

Programmer
May 29, 2002
16
US
i am trying to run a program(.exe) from vbscript in EONReality, but i'm having a problem. i don't get any error message and it appears to work correctly, but i can tell the program isn't executed because it would write to a file. there is no problem with the program itself; when i execute it manually, it works and writes to the file. the script i use to run it:

Set shell = CreateObject("WScript.Shell")
shell.Run(Path&"pos_predic.exe")

where Path is correct. if anyone has any ideas as to why this isn't working, i would appreciate all help.
thanks,
kfarrell
 
I actually have the same problem.
I think the problem is the Path.
If you have spaces in your path (like c:\program files\myprogram), the path has to be between quotes.
I think you should use something like
shell.run(chr(34) & path & chr(34) & "pos_predic.exe")

Another thing to consider:
1. Is shell not a reserved word of vbscript ? Maybe should you choose oShell.
2. if you use shell.run with ( ) , you've to use:
result= shell.run(...)
without a variable, it is shell.run path & "..."

I'm not sure it's the solution, but I hope it can help.



 
thank you for the tips, but the problem still arises. the wierd thing is, i see the shell flash as if the program executed when it was supposed to, but the values in the written file don't change as they should. yet as i said before, when i double click on the .exe program, it runs and changes the values in the written file. it just doesn't work when executed through vbscript. i am perplexed, and i will be grateful any more suggestions you or anyone can give.
currently trying:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "d:\users\kim\henry\pos_predic.exe"

thanks,
kfarrell
 
could it be a problem that there are two hard drives, d:\ might not be the default... do i need to change directory in the shell, and if so how can i do that?
just a thought, thanks again anybody.
kfarrell
 
kimbly,

Try this. This works on my system.

Set WshShell = CreateObject("WScript.Shell")
WshShell.run ("cmd /c " & "c:\mydir\mytest.vbs")


fengshui_1998
 
ok, i am definately really close to having this working. using "cmd /d" i get the shell, but because of the program i'm working in (EONReality), it starts in the directory "program files\eon reality\eon 3.0\eon base". do you know an easy way to change it to "users\kim\henry" through vbscript? thanks, i appreciate all the help everyone!
kfarrell

currently trying:
WshShell.Run "cmd d\ " & "d:\users\kim\henry\pos_predic.exe"
 
oops i meant "cmd /d"
just a typ-o in the post, the code is correct
 
kimbly,

You can chain commands together using, I believe, the colon.

For instance,

WshShell.Run "cmd /d " & "d:" & " : " & _
"cd "users\kim\henry" & " : " & _
"pos_predic.exe"


fengshui_1998

 
unfortunately that is also not working.
i get cmd.exe opened with
D:\Program Files\EON Reality\EON 3.0\EON Base>

that is all the vbscript does.
i myself can type "cd ..\..\..\..\users\kim\henry"
to change directory, and "pos_predic.exe" to execute the program, but the code does not do this for me.

currently trying:
WshShell.Run "cmd /d " & "d:" & " : " & _
"cd ..\..\..\..\users\kim\henry" & " : " & _
"pos_predic.exe"

thanks,
kfarrell
 
kimbly,

I believe the problem is with the spaces in the path just as Derkrieger stated. What is the complete path to this executable?

fengshui_1998
 
the complete path is "D:\users\kim\henry\pos_predic.exe"

however when cmd.exe opens, it starts in the directory
"D:\Program Files\EON Reality\EON 3.0\EON Base"

thanks,
kfarrell
 
kimbly,

Try using this absolute path.


Cheers,
fengshui_1998


WshShell.Run "cmd /d " & "d:" & " : " & _
"cd D:\users\kim\henry" & " : " & _
"pos_predic.exe"

 
Using the Windows command emulator (cmd.exe), you execute sequential commands using the &.

Set oShell = WScript.Createobject("WScript.Shell")
oShell.Run "cmd /K D: & CD \users\kim\henry\ & pos_predic",1,True

If you want to the command window to close immediately after the program terminates, use /C instead of /K. Jon Hawkins
 
jonscott;

Thanks, jonscott. I couldn't remember if it was that or the ":" because you can use that in vbscript.

Cheers,
fengshui_1998
 
thanks everyone for your help!
i will be away from the project for the weekend, but as soon as i get back i will try that, and let you know how it goes. thanks again!
:)
kfarrell
 
thanks to all, it's working now.
kfarrell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top