?
Solved

Shell command problems

Posted on 2002-05-27
15
Medium Priority
?
254 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:Patterson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
  • +1
15 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7037624
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7037628
I meant:
But calc.exe is intalled in "c:\windows" folder not in "c:\program files" folder.
0
 
LVL 44

Accepted Solution

by:
bruintje earned 1600 total points
ID: 7037659
Hi Patterson,

just a dumb shot at this try

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

:O)Bruintje
0
Independent Software Vendors: 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!

 
LVL 44

Expert Comment

by:bruintje
ID: 7037661
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7037701
Hi Bruintje, too quiet Office TA?
:D
0
 
LVL 3

Author Comment

by:Patterson
ID: 7037719
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7037727
holy smoke!!!
:)))))
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7037734
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
 
LVL 3

Author Comment

by:Patterson
ID: 7037749
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 7037784
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
 
LVL 44

Expert Comment

by:bruintje
ID: 7037795
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
 
LVL 3

Author Comment

by:Patterson
ID: 7037806
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7037815
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 7037817
Thanks for clarifying, Patterson, and confirming that the actions taken are correct.

All is well.

Moondancer - EE Moderator
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7038605
indeed thanks for clarifying, sorry for being trigger happy now and then.....i'm working on it ;)
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question