PDA

View Full Version : Shell Command results in Runtime Error 5 - but path appears to exist



tpq86
08-24-2022, 02:28 AM
I am running code which essentially boils down to:


program_test = "C:\Program Files\program company\program\3.2\program.exe"
process_id = Shell(program_test, 2)

But I get a run time error 5, if I paste the program_test value directly into the command line interface It opens the program. In fact It even appears to be a valid path when I use the vba code


TestIfPathExists = Dir(program_test)

georgiboy
08-24-2022, 03:02 AM
Does the below work:

program_test = """C:\Program Files\program company\program\3.2\program.exe"""
process_id = Shell(program_test, 2)

tpq86
08-24-2022, 03:24 AM
Nope

arnelgp
08-24-2022, 03:37 AM
can you try:

CreateObject("Shell.Application").Namespace(0).ParseName("C:\Program Files\program company\program\3.2\program.exe").InvokeVerb ("Open")

tpq86
08-24-2022, 04:59 AM
That worked! thank you so much! can I follow up with two questions ?

1. What was the underlying problem ?
2. I need to call the program with a suffix(?) specifically I need to call "C:\Program Files\program company\program\3.2\program.exe" -SaveExports but it appears I cant just add this extra input to your code - is it possible to add it to it ?

Paul_Hossler
08-24-2022, 05:13 AM
You can try something like this, but probably requires some tweaking



Application.Run "C:\Program Files\program company\program\3.2\program.exe", "-SaveExports"