Shell run-time error 5, invalid procedure call or argument

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dennijr
    New Member
    • May 2007
    • 17

    #1

    Shell run-time error 5, invalid procedure call or argument

    ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong

    heres the simplist code possible:

    Code:
    Private Sub IExplorer_Click()
    a = Shell("C:\Program Files\Internet Explorer\Iexplore.exe http://www.google.ca", vbMaximizedFocus)
    End Sub
    i have a program thats been on my desktop for about a month now that uses these 3 lines of code(supposed to be 3 lines but it doesnt quite fit) and its been working perfectly up till today. I attempted to run it, then when it got to this part, it highlighted

    Code:
    a = Shell("C:\Program Files\Internet Explorer\Iexplore.exe http://www.google.ca", vbMaximizedFocus)
    and a messagebox appeared saying run-time error 5, invalid procedure call or argument. I tried making an even simpler program that just opened notepad during form_load, but it still didnt work, same error. It doesnt make any sence, all that stuff used to work perfectly.
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by dennijr
    ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong

    heres the simplist code possible:

    Code:
    Private Sub IExplorer_Click()
    a = Shell("C:\Program Files\Internet Explorer\Iexplore.exe http://www.google.ca", vbMaximizedFocus)
    End Sub
    i have a program thats been on my desktop for about a month now that uses these 3 lines of code(supposed to be 3 lines but it doesnt quite fit) and its been working perfectly up till today. I attempted to run it, then when it got to this part, it highlighted

    Code:
    a = Shell("C:\Program Files\Internet Explorer\Iexplore.exe http://www.google.ca", vbMaximizedFocus)
    and a messagebox appeared saying run-time error 5, invalid procedure call or argument. I tried making an even simpler program that just opened notepad during form_load, but it still didnt work, same error. It doesnt make any sence, all that stuff used to work perfectly.
    Hi,
    I think this is because of the second argument, "vbmaximizedfoc us" maybe you don have the constants set, why dont you try using the constan's value instead, something like

    a = Shell("C:\Progr am Files\Internet Explorer\Iexplo re.exe http://www.google.ca", 3)

    hope that helps

    Comment

    • dennijr
      New Member
      • May 2007
      • 17

      #3
      Originally posted by kadghar
      Hi,
      I think this is because of the second argument, "vbmaximizedfoc us" maybe you don have the constants set, why dont you try using the constan's value instead, something like

      a = Shell("C:\Progr am Files\Internet Explorer\Iexplo re.exe http://www.google.ca", 3)

      hope that helps
      nope, didnt work = ( , thanks for making an attempt tho

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by kadghar
        I think this is because of the second argument, "vbmaximizedfoc us" maybe you don have the constants set...
        That would produce a compile error, not runtime.

        I thought somebody was saying recently that Shell couldn't handle a path with spaces in it. Perhaps ShellExecute is better. Have a look at this thread.

        Comment

        • pureenhanoi
          New Member
          • Mar 2007
          • 175

          #5
          Originally posted by dennijr
          ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong

          heres the simplist code possible:

          Code:
          Private Sub IExplorer_Click()
          a = Shell("C:\Program Files\Internet Explorer\Iexplore.exe http://www.google.ca", vbMaximizedFocus)
          End Sub
          i have a program thats been on my desktop for about a month now that uses these 3 lines of code(supposed to be 3 lines but it doesnt quite fit) and its been working perfectly up till today. I attempted to run it, then when it got to this part, it highlighted

          Code:
          a = Shell("C:\Program Files\Internet Explorer\Iexplore.exe http://www.google.ca", vbMaximizedFocus)
          and a messagebox appeared saying run-time error 5, invalid procedure call or argument. I tried making an even simpler program that just opened notepad during form_load, but it still didnt work, same error. It doesnt make any sence, all that stuff used to work perfectly.
          I sometime meet this type of error. (Worked-code goes fault). I tried resolving problem and found the reason: missing one or more library in preference.
          On the Project menu, choose Preference. One dialoge appears show all preferences of your project. If you see atleast one line have "...Missing...l ibrary...", so it is the fault.
          If this library doesnot need for project, so simply un-check the library and click OK. If this really need, you can see the path to the ".dll" file. If the file is missing, u need copy one file to that location, or maybe install some other soft-wares that provide this "dll" file.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by pureenhanoi
            I sometime meet this type of error. (Worked-code goes fault). I tried resolving problem and found the reason: missing one or more library in preference...
            Are you sure you don't mean reference?

            Comment

            • dennijr
              New Member
              • May 2007
              • 17

              #7
              Originally posted by Killer42
              That would produce a compile error, not runtime.

              I thought somebody was saying recently that Shell couldn't handle a path with spaces in it. Perhaps ShellExecute is better. Have a look at this thread.
              I've heard that too, and I also tried ShellExecute cause of it, but it still wasn't working, and besides, it doesn't make any sense that Shell can't handle spaces cause it was working before ...

              Originally posted by pureenhanoi
              I sometime meet this type of error. (Worked-code goes fault). I tried resolving problem and found the reason: missing one or more library in preference.
              On the Project menu, choose Preference. One dialoge appears show all preferences of your project. If you see atleast one line have "...Missing...l ibrary...", so it is the fault.
              If this library doesnot need for project, so simply un-check the library and click OK. If this really need, you can see the path to the ".dll" file. If the file is missing, u need copy one file to that location, or maybe install some other soft-wares that provide this "dll" file.
              Ok, I tried that, but I didn't find anything saying missing library, and there's only 4 things checked, so as of now, I'm gonna try searching on Google for the dll file that shell uses, if I can't find anything that way, then I'll just select all the references and test if it works, if it doesn't, then I'm stuck again, if it does work, then I have to find out which one it is lmao...

              EDIT: kk, in system32, theres shell32, shell, shell manager, shell style and shellvRTF. Shell manager and shell32 are the only ones that VB6 will add a reference to, and if I add them and select them, I still get the same error,
              any other ideas?
              PS. ty to all people trying to help, it's greatly apreciated

              Comment

              • kadghar
                Recognized Expert Top Contributor
                • Apr 2007
                • 1302

                #8
                Originally posted by dennijr
                ive heard that too, and i also tried shellexecute cause of it, but it still wasnt working, and besides, it doesnt make any sence that shell cant handle spaces cause it was working before ...



                ok, i tried that, but i didnt find anything saying missing library, and theres only 4 things checked, so as of now, im gonna try searching on google for the dll file that shell uses, if i cant find anything that way, then i'll just select all the references and test if it works, if it dosnt, then im stuck again, if it does work, then i have to find out which one it is lmao...

                EDIT: i found shell's dll, and wadda u no, its called shell32.dll, ima try to get it to work now...

                PS. ty to all ppl trying to help, its greatly apreciated
                Hi, I dont know how much this helps, but if in the worst case you get stuck, use an object with an internet explorer application in it.
                check this out:

                VB Forum - On Click

                It might be an alternative.

                Comment

                • dennijr
                  New Member
                  • May 2007
                  • 17

                  #9
                  Originally posted by kadghar
                  Hi, I dont know how much this helps, but if in the worst case you get stuck, use an object with an internet explorer application in it.
                  check this out:

                  VB Forum - On Click

                  It might be an alternative.
                  well, it does work for internet explorer, but i dont know how to make it work for other programs aswell...

                  ty

                  i can use this in the meantime, BUT, i would still like to figure out why i cant use shell anymore

                  Comment

                  • dennijr
                    New Member
                    • May 2007
                    • 17

                    #10
                    Originally posted by Killer42
                    That would produce a compile error, not runtime.

                    I thought somebody was saying recently that Shell couldn't handle a path with spaces in it. Perhaps ShellExecute is better. Have a look at this thread.
                    i didnt use shell execute from that link, but i did finally find annother source, which had what i needed on it, and i can change it for more than one program

                    but...

                    i still wanna no why my shell doesnt work anymore .... and its not cause of spaces in the title, cause i get the same error even with files that dont have spaces

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Originally posted by dennijr
                      ... i still wanna no why my shell doesnt work anymore .... and its not cause of spaces in the title, cause i get the same error even with files that dont have spaces
                      I'd be really curious to know what went wrong, too. I finally got around to trying your original example, and of course it works. So for some reason your system simply became unable to fire off another process. Could this have been some security measure you weren't aware had been implemented?

                      Another thought which occurs - if, say, you had something which was being displayed "system modally", then maybe trying to start up anything with the focus causes that error. Could you go back and try the original version again to ensure the problem is still there, then try it without giving it the focus?

                      That's about it - I'm all guessed out.

                      Comment

                      • dennijr
                        New Member
                        • May 2007
                        • 17

                        #12
                        Originally posted by Killer42
                        I'd be really curious to know what went wrong, too. I finally got around to trying your original example, and of course it works. So for some reason your system simply became unable to fire off another process. Could this have been some security measure you weren't aware had been implemented?

                        Another thought which occurs - if, say, you had something which was being displayed "system modally", then maybe trying to start up anything with the focus causes that error. Could you go back and try the original version again to ensure the problem is still there, then try it without giving it the focus?

                        That's about it - I'm all guessed out.
                        For the second part, I thought about that too at one point where I was trying to do everything I could think of to get it to work, I made it as basic as it could possibly be.

                        For the first part though, that could be what it is, that somehow my security isn’t allowing shell to connect any more, but I haven’t changed anything security-wise recently.

                        There were 2 things that I did in between when it was and wasn’t working (not including things I do all the time, like msn messenger etc).

                        One of which was downloading a transparent picturebox user control for use with another program in VB6 (which works amazingly well) and at the time I wasn’t quite sure how to get the user control to work as I had never used it before, so I attempted to put it into system32, and later removed it of course. The second thing I did was download a program made in C++ coding.

                        Could the user control for VB6 cause an error, even without the trans picbox user control in the program? I know the C++ program is safe, but it does connect to the internet to receive updates, could something inside the program have stoped shell from working by some sort of conflict?

                        could either of these (or maybe still something else) be causing an error?

                        Thanks again for trying to help.

                        Comment

                        • crapycoder
                          New Member
                          • Nov 2008
                          • 4

                          #13
                          Hi Guys,

                          i have a similar kind of problem which i faced while developing Excel VBA Macro.

                          i have two lines of code in different modules in the same project

                          1. RetVal = Shell(FILE_PATH & "EXTRACT.BA T")

                          2. RetVal = Shell(FILE_PATH & "EXTRACT.BA T")


                          Then 1st shell command works fine. and i did not get any error.

                          but when i tried to execute the 2nd module which contains the same shell method as in (2), i am getting the error "Invalid Procedure call or argument", Runtime Error 5.

                          and it also works well when i say "var = Shell("calc.exe ")

                          i am very much confused with the behaviour.

                          Please anyone in this world can help this.

                          Thanks

                          Crapy Coder

                          Comment

                          • wakerunner
                            New Member
                            • Dec 2008
                            • 2

                            #14
                            I started having the same problem with Shell. To begin with all shell's in my program worked, then a few stopped working, there were no changes to my system. Then more and more of them quit working.

                            My development system is Vista with UAC on, but it has been for over a year before they shell started to crap out. I also did not download any new service packs/ updates to Vista before Shell quit working.

                            Right now there are still some Shells that work IE

                            Retval=Shell("n otepad.exe",Vbn ormalfocus)... works right now
                            Retval = shell(Mypath$ & "my program.exe") ... worked until yesterday
                            Retval = shell(Mypath$ & "my other program.exe") ... worked until a month ago
                            Retval = shell(Mypath$ & "my other other program.exe") ... worked until a 2 months ago

                            I have searched the net trying to find out why but no joy. I believe it has something to do with Vista UAC. Anyway my solution is to use API with:

                            ShellExecute Me.hWnd, vbNullString, Mypath$ + "My Prog.exe", vbNullString, vbNullString, 1

                            It seems to be working now... who knows if it will tomorrow??

                            Comment

                            • DrardyLarmbab
                              New Member
                              • Dec 2008
                              • 1

                              #15
                              6 Your site is very helpful. Really it is very useful!

                              Hello
                              I've just registered to say your site is very useful and nicely done!
                              Thank you very much for your work.

                              Cheers!

                              Sorry for offtopic.

                              Comment

                              Working...