Shell command problems

I'm experiencing a wierd problem when trying to execute a Shell command within a simple VB program. I am trying to run Shell("d:\program files\calc.exe", vbMaximizedFocus) and I am getting Invalid Procedure call or argument. If I try and run Shell("d:\temp\calc.exe", vbMaximizedFocus) it works fine, same with Shell("c:\program files\calc.exe", vbMaximizedFocus). It's just that one folder on the D drive that is causing this error. Within a VB program I can write to a text file within the d:\program files\ folder so I am cunfused as to why this error is occuring.

If anyone can shed some light on this I would appreciate it.

Thanks,

Patterson
LVL 3
PattersonAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
bruintjeConnect With a Mentor Commented:
Hi Patterson,

just a dumb shot at this try

Shell("d:\progra~1\calc.exe", vbMaximizedFocus)

:O)Bruintje
0
 
Richie_SimonettiIT OperationsCommented:
Try surrounding the path with double quotes:
Shell(chr$(34) & "d:\program files\calc.exe" & chr$(34), vbMaximizedFocus)
But calc.exe is intalled in c:\windows direcory not in program files folder.
0
 
Richie_SimonettiIT OperationsCommented:
I meant:
But calc.exe is intalled in "c:\windows" folder not in "c:\program files" folder.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
bruintjeCommented:
it works from the commandline like that, getting the 8 dos character trouble when doing things in spaced directories like

"program files"

or

"my documents"

:O)Bruintje
0
 
Richie_SimonettiIT OperationsCommented:
Hi Bruintje, too quiet Office TA?
:D
0
 
PattersonAuthor Commented:
For some crazy reason that worked so I am very happy. Doesn't explain why I could run c:\program files\... but oh well. Richie_Simonetti solution of the chr(34) addition almost worked but I am passing parameters to the exe I am calling and I was getting file not found errors.

Thanks again,

Patterson
0
 
Richie_SimonettiIT OperationsCommented:
holy smoke!!!
:)))))
0
 
bruintjeCommented:
well i explained why it worked, it's dos 8 character limit, no spaces allowed becuase it will be seen as another part of the string

programfiles will work for that reason and program fiels will not...

i will protest my C grade, better had CS first lower the points to give me 100 points and an A then 800 points oand a C

sorry i'm not very happy when you explain the thing and still get a C. next time just don't accept it that's always better then making someone not so happy with a C

:O)Bruintje

Richie>>>Office is too quiet and i just came back from a very wonderfull evening so though maybe i could give this a try and i guess my simple sentence of a dumb try made it seem all too simple that's why i added the second comment. just as you i don't like a C if it could also be different.......i don't mind to lower the points but it solved the problem so it's worth an A
0
 
PattersonAuthor Commented:
I'm sorry about the C grade... I had A selected in the box but I clicked on the back button to get Richie_Simonetti's name so the form must have reset when I hit forward again...

I'll make a new question with more points and give you an A for them.

Patterson
0
 
MoondancerCommented:
I corrected the grade from C to A, but is that what you wanted?  This is a bit unclear.  Were you planning to also post a new question for Richie for this?

Sorry to confuse, but am confused here.

Moondancer - EE Moderator
0
 
bruintjeCommented:
now i'm a bit confused also, if it wasn't your intention to grade my answer at all

say so, Moondancer or maybe someone else from CS can reset the points on the Q and maybe some way to take them off my account? and distribute them back?

I don't want points not deserved if it wasn't so.....

sorry about the confusion, i'll leave it here :) way too tired
0
 
PattersonAuthor Commented:
I wanted to give bruintje an A but the form must have been reset when I hit the back button and I did not re-check the A when I came back.

Sorry to confuse you guys and thanks for changing the grade to an A because that is the grade I intended to give.

Thanks,

Patterson
0
 
Richie_SimonettiIT OperationsCommented:
I don't think that Patterson would give any points to me.
what i understood is he/she did try to copy my name from previous page and when comes back, the page was setted to "C" grade again(?) (which is not the default ;).
The addition of another question was for give Bruintje the points that he/she has missed here for that "infamous" "C" grade.
When all of this get well, i would like to post some coments regarding this question.
Cheers
0
 
MoondancerCommented:
Thanks for clarifying, Patterson, and confirming that the actions taken are correct.

All is well.

Moondancer - EE Moderator
0
 
bruintjeCommented:
indeed thanks for clarifying, sorry for being trigger happy now and then.....i'm working on it ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.