Solved

Shell command problems

Posted on 2002-05-27
15
245 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
  • 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 400 total points
ID: 7037659
Hi Patterson,

just a dumb shot at this try

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

:O)Bruintje
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

772 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