Invalid Procedure call or argument while using shell?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HaggardSmurf
    New Member
    • Oct 2006
    • 12

    Invalid Procedure call or argument while using shell?

    Code:
    Private Sub Downloader1_DownloadComplete(MaxBytes As Long, SaveFile As String)
        If MsgBox("Donwnload Finished. Would you like to install now?", vbInformation + vbYesNo, "Blue Cherry Media Player") = vbYes Then
            Filename = App.Path + "\BCMP " + Site + ".zip"
            Call OpenDownload
        End If
    End Sub
    
    Sub OpenDownload()
        Shell Filename, vbNormalFocus
    End Sub
    Edit: Site is just the file version so right now it will say 2.2.2.269


    Well I have made a media player that I think is actually very good but I thought the simplest thing ever is now turning out to be a pain in the a**.

    Basically I use an Inet control and it connects to a text document on my site. If the text document has a different number then the file version of the exe (File version is included in the coding) then it downloads the new file. There really isnt a problem with that. Its after the download is finished a message box comes up saying would you like to install now? and if you click yes it will execute the install (since im still working out the bugs its just a .zip archive). When it gets to the shell part I get Invalid Procedure call or argument and it highlights:

    Code:
    Shell Filename, vbNormalFocus
    Ive tried Call Shell Filename, vbnormalfocus but it didnt work. Ive tried all kinds of things and still doesnt work. It doesnt matter where the file is either.

    Help would be appreciated.
  • HaggardSmurf
    New Member
    • Oct 2006
    • 12

    #2
    Originally posted by HaggardSmurf
    Code:
    Private Sub Downloader1_DownloadComplete(MaxBytes As Long, SaveFile As String)
        If MsgBox("Donwnload Finished. Would you like to install now?", vbInformation + vbYesNo, "Blue Cherry Media Player") = vbYes Then
            Filename = App.Path + "\BCMP " + Site + ".zip"
            Call OpenDownload
        End If
    End Sub
    
    Sub OpenDownload()
        Shell Filename, vbNormalFocus
    End Sub
    Edit: Site is just the file version so right now it will say 2.2.2.269


    Well I have made a media player that I think is actually very good but I thought the simplest thing ever is now turning out to be a pain in the a**.

    Basically I use an Inet control and it connects to a text document on my site. If the text document has a different number then the file version of the exe (File version is included in the coding) then it downloads the new file. There really isnt a problem with that. Its after the download is finished a message box comes up saying would you like to install now? and if you click yes it will execute the install (since im still working out the bugs its just a .zip archive). When it gets to the shell part I get Invalid Procedure call or argument and it highlights:

    Code:
    Shell Filename, vbNormalFocus
    Ive tried Call Shell Filename, vbnormalfocus but it didnt work. Ive tried all kinds of things and still doesnt work. It doesnt matter where the file is either.

    Help would be appreciated.

    Nvm I used the shell execute code in this site.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      You used the code from this site? Well, there's your problem then... :D

      Seriously, I'd suggest you set a breakpoint on the Shell command and examine the content of FileName. My guess is you'll find it's empty, or something.

      Quick question - do you have Option Explicit specified? If not, I'd recommend using it. (For VB6, that is - not sure whether it still applies in VB.Net, and I don't know what version you're using, though I'd guess VB6 from the look of the code.)

      Comment

      • Brian
        New Member
        • Oct 2005
        • 2

        #4
        I am getting this same message, not sure why... it has worked for years... but my pate and file name are correct and valid?

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by Brian
          I am getting this same message, not sure why... it has worked for years... but my pate and file name are correct and valid?
          How about moving away from Shell entirely? I seem to recall a few years back having to convert some of my code to use an API call to open various types of file because Shell wouldn't recognise them as executable.

          Wish I could remember the API name, though...

          Um...

          Could be ShellExecute perhaps.

          Comment

          • Paul Longtin
            New Member
            • Nov 2007
            • 2

            #6
            Just in the last few months, I have had problems with Shell in VB6. Depending what your program was doing before the "Shell" statement can effect it. Formerly, your current directory followed the shell statement. I believe it to be a Microsoft patch. I can run a compiled program on one of our servers that works fine. If I recompile the exact same code, shell no longer runs correctly. Now, it seems to execute without changing the directory. I use "ChDrive" and then "ChDir" before running the shell statement with no problems.

            I use:
            [Dim RanIt As Double ' Variant
            RanIt = Shell(MyFile, vbNormalFocus)]

            Also, did you check for spaces in the file name?

            The other solution is to use the API. "Shell" doesn't like Adobe programs.

            [Private Declare Function ShellExecute Lib "shell32.dl l" Alias "ShellExecu teA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

            Dim RanIt As long

            RanIt = ShellExecute(0& , "open", MyFilePath & MyFileName, vbNullString, vbNullString, 1) 'SW_SHOWNORMAL = 1]

            Comment

            • 9815402440
              New Member
              • Oct 2007
              • 180

              #7
              hi
              just using Shell dont do the thing

              use following code
              note: this is code is to run F:\Documents and Settings\XPPRES P3\My Documents\9888. xls"

              ChDir "F:\Documen ts and Settings\XPPRES P3\My Documents"
              Shell "Start 9888.xls", vbNormalFocus

              chdir is used because Start support dos file nameing conventions.

              regards
              manpreet singh dhillon hoshiarpur

              Comment

              Working...