Announcement

Collapse
No announcement yet.

ShellExecute XP SP3

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ShellExecute XP SP3

    I have an old usb-flash-drive with write protect switch.

    ShellExecute brings a bug if I would like to start a EXE file and the usb flash drive is write protected. Is the bug known? (Bug comes only under XP SP3.)

    Code:
    ShellExecute 0, "open", "prog.exe", "", "x:\", 1

    #2
    What bug?

    From code shown all I can see is an error raised because it is write protected so you cant open it...

    I have not tried it...but from 1st glance I bet thats the case
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

    Comment


      #3
      >(Bug comes only under XP SP3.)

      Um, then maybe the 'bug' is in XP/SP3 and not the Microsoft ShellExecute function?

      If you need a workaround, you can try....
      • ShellExecuteEx
      • CreateProcess
      • PB "SHELL"


      If all those fail, try open the EXE file for read-only, copy it somewhere and execute from there. Or maybe just Try Filecopy or copyfile (one is PB one is WinAPI).

      Need a folder with guaranteed "write permission?" Use GetTempPath() winapi function.
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


        #4
        'What error does this return?
        Code:
        #DIM ALL
        #INCLUDE "win32api.inc"
        DECLARE SUB ShellExecuteErrors(ErrorNumber AS LONG)
        FUNCTION PBMAIN () AS LONG
          LOCAL result AS LONG
          result = SHELLEXECUTE(0,"open","prog.exe","","x:\",%SW_SHOWNORMAL)
          ShellExecuteErrors result
          SLEEP 2000
        END FUNCTION
        SUB ShellExecuteErrors(ErrorNumber AS LONG)
          IF ErrorNumber > 32 THEN EXIT SUB
         'If the function fails, the return value is an error value that is less than or equal to 32. The following table lists these error values:
         
        SELECT CASE ErrorNumber
          CASE 0
            ? "The operating system is out of memory or resources."
          CASE  %ERROR_FILE_NOT_FOUND
              ?"The specified file was not found."
          CASE %ERROR_PATH_NOT_FOUND
             ? "The specified path was not found."
          CASE %ERROR_BAD_FORMAT
            ? "The .EXE file is invalid (non-Win32 .EXE or error in .EXE image)."
          CASE %SE_ERR_ACCESSDENIED
            ? "The operating system denied access to the specified file."
          CASE %SE_ERR_ASSOCINCOMPLETE
            ? "The filename association is incomplete or invalid."
          CASE %SE_ERR_DDEBUSY
            ? "The DDE transaction could not be completed because other DDE transactions were being processed."
          CASE %SE_ERR_DDEFAIL
            ? "The DDE transaction failed."
          CASE %SE_ERR_DDETIMEOUT
             ? "The DDE transaction could not be completed because the request timed out."
          CASE %SE_ERR_DLLNOTFOUND
            ?  "The specified dynamic-link library was not found."
          CASE %SE_ERR_FNF
            ? "The specified file was not found."
          CASE %SE_ERR_NOASSOC
            ? "There is no application associated with the given filename extension."
          CASE %SE_ERR_OOM
            ? "There was not enough memory to complete the operation."
          CASE %SE_ERR_PNF
            ? "The specified path was not found."
          CASE %SE_ERR_SHARE
            ? "A sharing violation occurred.
          CASE ELSE
            ? "ShellExecute value was" + STR$(ErrorNumber)
        END SELECT
        END SUB
        #IF 0
        SW_HIDE   Hides the WINDOW AND activates another window.
        SW_MAXIMIZE   Maximizes the specified window.
        SW_MINIMIZE   Minimizes the specified WINDOW AND activates the NEXT top-level WINDOW IN the Z order.
        SW_RESTORE  Activates AND displays the window. IF the WINDOW IS minimized OR maximized, Windows restores it TO its original SIZE AND position. An application should specify this flag when restoring a minimized window.
        SW_SHOW   Activates the WINDOW AND displays it IN its current SIZE AND position.
        SW_SHOWDEFAULT  Sets the show state based ON the SW_ flag specified IN the STARTUPINFO structure passed TO the CreateProcess FUNCTION by the program that started the application. An application should CALL ShowWindow WITH this flag TO SET the initial
        show state OF its MAIN window.
        SW_SHOWMAXIMIZED  Activates the WINDOW AND displays it AS a maximized window.
        SW_SHOWMINIMIZED  Activates the WINDOW AND displays it AS a minimized window.
        SW_SHOWMINNOACTIVE  Displays the WINDOW AS a minimized window. The active WINDOW remains active.
        SW_SHOWNA   Displays the WINDOW IN its current state. The active WINDOW remains active.
        SW_SHOWNOACTIVATE   Displays a WINDOW IN its most recent SIZE AND position. The active WINDOW remains active.
        SW_SHOWNORMAL   Activates AND displays a window. IF the WINDOW IS minimized OR maximized, Windows restores it TO its original SIZE AND position. An application should specify this flag when displaying the WINDOW FOR the first time.
        IF lpFile specifies a document file, nShowCmd should be zero.
        #ENDIF
        Last edited by Mike Doty; 14 Jun 2008, 01:09 AM.

        Comment


          #5
          From what I see is that he is running the EXE locally(?) but reading files on the flash drive - drive X:\

          If that's the case, it depends on how the app opens the files. Assuming you are using PB file statements, on a read-only drive/folder/file you must use OPEN <file> FOR <mode> ACCESS READ AS #<num>. The "ACCESS READ" will open the file in read-only mode, otherwise you will get an access denied error.
          kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

          Comment


            #6
            From what I see is that he is running the EXE locally(?) but reading files on the flash drive - drive X:\
            Another psychic! How can you know what "prog.exe" is doing or what the "X:\" parameter means?

            I think Mr. Doty is in the right path... "check your function call's success/fail code before blithely calling it a 'bug'"
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


              #7
              ShellExecute - no error code return.

              This is a Windows message?!



              The message does not appear with CDs. Only at write-protected USB flash drives.

              (With WinExec or Shell (PB) is all OK.)
              Last edited by Bernhard Fomm; 14 Jun 2008, 08:11 AM.

              Comment


                #8
                Another psychic!
                Well, with the information posted up until that point, that means all of us were taking a guess. Even you
                kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                Comment


                  #9
                  Tried to translate using http://translate.google.com/translate_t?sl=de&tl=en

                  The disc is write and can not described will.
                  Remove the protection of the disc USB_128MB in run G:
                  Last edited by Mike Doty; 14 Jun 2008, 09:29 AM.

                  Comment


                    #10
                    Curious, try changing attribute of program to read-only (since that may be the attribute if run from a CD) and then write protect USB drive.
                    With WinExec or Shell (PB) is all OK.)
                    Is this a question or did it work using them?
                    Last edited by Mike Doty; 14 Jun 2008, 09:47 AM.

                    Comment


                      #11
                      Originally posted by Mike Doty View Post
                      Is this a question or did it work using them?
                      A question ends "?".

                      Comment


                        #12
                        I do not understand why the bug appears only under XP SP3. Everything is all right under XP SP2.

                        I then take SHELL (PB). Thanks to all.

                        Comment


                          #13
                          PB shell works?
                          Please let us know what Microsoft says when you report it.
                          Last edited by Mike Doty; 14 Jun 2008, 01:43 PM.

                          Comment


                            #14
                            Originally posted by Mike Doty View Post
                            PB shell works?
                            Yes, PB shell works - also WinExec

                            Comment

                            Working...
                            X
                            😀
                            🥰
                            🤢
                            😎
                            😡
                            👍
                            👎