Announcement

Collapse
No announcement yet.

shell command

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

  • #21
    Pierre, size is 623104, Attribute is 20. I get Error 50(0x32) Request is not supported, then Shell Execute gives error 5

    Comment


    • #22
      Paul - It better

      Comment


      • #23
        To be sure that I follow...
        Windows is Windows 10 64 bit.
        The ShellInfo.hInstApp = 5 aka ERROR_ACCESS_DENIED

        What is the number in the caption title of the error 50 message box?
        It should be 1, 2, or 4.

        If you got "Request is not supported" for Wow64DisableWow64FsRedirection()
        then that explain why you got the problem.

        Since this is an unusual problem, what if you run it as admin, or with the av off?
        Last edited by Pierre Bellisle; 4 Dec 2018, 04:33 PM.

        Comment


        • #24
          Mike G.

          From post #17 by Eric
          I googled "can't shell osk" and FWIW it looks like VB and Access have the same problem. The workaround in both cases is to use ShellExecute instead of SHELL
          My previous test only worked while in PBEDIT.
          This works:
          Code:
          #INCLUDE "win32api.inc"
          FUNCTION PBMAIN AS LONG
           LOCAL Wow64Value AS DWORD
           LOCAL zText AS ASCIIZ * 256
           Wow64DisableWow64FsRedirection(Wow64Value)  'this is required
           zText = "osk.exe"
           ShellExecute (%NULL, "OPEN", zText, BYVAL %NULL, CURDIR$, %SW_SHOWNORMAL)
          END FUNCTION
          https://www.tesla.com/roadster

          Comment


          • #25
            Pierre, Here is the debugger response:
            "onecoreuap\inetcore\urlmon\zones\zoneidentifier.cxx(359)\urlmon.dll!73FB0880: (caller: 73FB06F8) ReturnHr(1) tid(4d38) 80070002 The system cannot find the file specified."

            Comment


            • #26
              Mike M, Here is the debugger response from your code.
              "onecoreuap\inetcore\urlmon\zones\zoneidentifier.cxx(359)\urlmon.dll!73FB0880: (caller: 73FB06F8) ReturnHr(1) tid(32dc) 80070002 The system cannot find the file specified."
              Im going to try to work with the AV next. There has to be something stupid blocking this shell.

              Comment


              • #27
                I deactivated the AV, same results as before.

                Comment


                • #28
                  And what was the number in the caption title of the error 50 message box?

                  Comment


                  • #29
                    Mike's program in post #24 works for me - Using Windows 10 Pro 64 bit Version 1803. I think the best thing to do would be to Run Process Monitor and determine the exact cause of the error. If you need my log to compare with let me know - but it should give you the cause of the error

                    Comment


                    • #30
                      Looks like there is a problem with the PBIDE Debugger when OS redirection is in play in Win10 Pro 64bit.

                      I see the same issue as Mike G when running Pierre's examples using the PB IDE Debugger in Win10 (even when ShellExecuteEx() is isolated within a pair of #DBUG CODE OFF/ON metastatements).

                      I don't see that problem when running the PB IDE Debugger in Win7 Pro 64bit.

                      In Win10 Pro 64Bit, the OSK is launched OK however when the IDE's Compile/Run option is selected (ie not in Debug mode).

                      Here's an example that should run OK in Win10 32 or 64bit,
                      Code:
                      #Dim All
                      #Compile Exe
                      #Include "WIN32API.INC"
                      
                      Declare Function DisableRedirection(OldValue As Long) As Long     ' for run-time (explicit) dynamic linking to functions in 64 bit Kernel32.dll
                      Declare Function ReEnableRedirection(OldValue As Long) As Long    ' that aren't available in 32 bit systems
                      '------------------/
                      
                      Function PBMain()
                       Local OSK      As String
                       Local PID      As Dword
                       Local OldValue As Long
                       Local hKernel32, dProcAddrDis, dProcAddrEn As Dword
                         OSK = "C:\windows\system32\osk.exe"
                         hKernel32 = GetModuleHandle("Kernel32.dll")
                      
                          dProcAddrDis = GetProcAddress(hKernel32, "Wow64DisableWow64FsRedirection")    ' get subroutine address from dll
                          dProcAddrEn  = GetProcAddress(hKernel32, "Wow64RevertWow64FsRedirection")
                      
                          If dProcAddrDis Then                                                          ' dealing with 64bit OS
                            CALL DWORD dProcAddrDis USING DisableRedirection(OldValue)
                              WinBeep 800,200
                              SHELLEXECUTE(%HWND_Desktop, "open", "C:\windows\system32\osk.exe", "", "", %SW_Show)
                            CALL DWORD dProcAddrEn USING ReEnableRedirection(OldValue)
                          Else                                                                        ' 32bit OS
                            pid = Shell( OSK )
                          End If
                      
                      End Function
                      '------------------/PBMain
                      Rgds, Dave

                      Comment


                      • #31
                        "And what was the number in the caption title of the error 50 message box?" OSK 5

                        Comment


                        • #32
                          I Have to leave for a while. I'll be back after midnight. I always appreciate the selfless dedication all of you show. I'm always amazed.

                          Comment


                          • #33
                            1. sfc /scannow
                            2. chkdsk /f
                            3. might use "everything" to search to if there are multiple copies of osk.exe
                            4. see if osk.exe ended up in a quarantined folder
                            5. run Malwarebytes
                            6 be sure a windows update isn't in progress
                            7 see if there are multiple virus checkers
                            8 see if path is correctly pointing to \windows\system32
                            System properties, advanced, Environment Variables

                            Just brain storming ...
                            https://www.tesla.com/roadster

                            Comment


                            • #34
                              removed screenshot of environment variables
                              Last edited by Mike Doty; 5 Dec 2018, 06:36 AM.
                              https://www.tesla.com/roadster

                              Comment


                              • #35
                                To Dave B: When I run your code in the debugger, I get file not found error. However, when I compile to exe, the keyboard pops up over and over, no problems. So what is going on?

                                Comment


                                • #36
                                  To Dave B: Do you mind if I use your code in my software? I'll give reference credit, Unfortunately, I'm the only person that will ever see it. Lol. As long as it works after compiling to exe, I'm good with that. The interesting thing is, I never tried compiling the standard shell command to exe. I bet it would have worked too. Is this a debugger problem?
                                  HTML Code:
                                  #COMPILE EXE
                                  #DIM ALL
                                  
                                  FUNCTION PBMAIN () AS LONG
                                      LOCAL iRet AS LONG
                                      iRet = SHELL("C:\Windows\system32\osk.exe",1)
                                  
                                  END FUNCTION
                                  After compiling the above code to exe, it does not work. So clearly your code is the answer but would the fact that the debugger gives an error, in both cases, indicate a a problem that needs to be addressed in the next IDE release? Should I send a note to the new owners so that they will be aware of the problem?

                                  Comment


                                  • #37
                                    Mike,

                                    Thanks for asking but as I believe my posts are a mostly a composite of things learned from these forums, I don't expect citations

                                    I think that the debugger isn't nimble enough to keep up with the tricks that the OS gets up to on the 'Windows On Windows' merry go round!

                                    I don't use the debugger much so I'd rather the new owners keep their focus elsewhere, at least for now
                                    Rgds, Dave

                                    Comment


                                    • #38
                                      The interesting thing is, I never tried compiling the standard shell command to exe …

                                      Compiled to d:\test\testosk.exe
                                      Created shortcuts to d:\test\testosk.exe from 3 operating systems
                                      Windows 10 64-bit
                                      Windows 10 32-bit (VirtualBox)
                                      Windows 7 32-bit (VirtualBox)

                                      Code:
                                      'Standard shell command only works here with Windows 7
                                      iRet = SHELL("C:\Windows\system32\osk.exe",1) 
                                      
                                      #INCLUDE "win32api.inc"  'OskTest.Bas
                                      FUNCTION PBMAIN AS LONG
                                      
                                       'Works only with 32-bit Windows 7
                                       LOCAL iRet AS LONG
                                       iRet = SHELL("C:\Windows\system32\osk.exe",1)
                                       ? "Done with PB SHELL, Click to test ShellExecute"
                                      
                                       'Works here with 64-bit Windows 10, 32-bit Windows 10, 32-bit Windows 7
                                       LOCAL Wow64Value AS DWORD
                                       LOCAL zText AS ASCIIZ * 256
                                       Wow64DisableWow64FsRedirection(Wow64Value)
                                       zText = "osk.exe"
                                       ShellExecute (%NULL, "OPEN", zText, BYVAL %NULL, CURDIR$, %SW_SHOWNORMAL)
                                      
                                      END FUNCTION
                                      https://www.tesla.com/roadster

                                      Comment


                                      • #39
                                        Hi Mike,
                                        If I may, do not forget about the use of Wow64RevertWow64FsRedirection in application code after Wow64DisableWow64FsRedirection, it's very important.
                                        See the note at Wow64DisableWow64FsRedirection

                                        "Note: The Wow64DisableWow64FsRedirection function affects all file operations performed by the current thread, which can have unintended consequences if file system redirection is disabled for any length of time. For example, DLL loading depends on file system redirection, so disabling file system redirection will cause DLL loading to fail. Also, many feature implementations use delayed loading and will fail while redirection is disabled. The failure state of the initial delay-load operation is persisted, so any subsequent use of the delay-load function will fail even after file system redirection is re-enabled. To avoid these problems, disable file system redirection immediately before calls to specific file I/O functions (such as CreateFile) that must not be redirected, and re-enable file system redirection immediately afterward using Wow64RevertWow64FsRedirection."

                                        Comment


                                        • #40

                                          Big catch, thank you and read about not using Enable!

                                          Wonder if it should be in a threadsafe function or protected with a critical section.


                                          Code:
                                          #INCLUDE "win32api.inc"
                                          FUNCTION PBMAIN AS LONG
                                          
                                           'Works only with 32-bit Windows 7
                                           LOCAL iRet AS LONG
                                           iRet = SHELL("C:\Windows\system32\osk.exe",1)
                                           ? "Done with PB SHELL, Click to test ShellExecute"
                                          
                                           'Works with 64-bit Windows 10, 32-bit Windows 10, 32-bit Windows 7
                                           LOCAL Wow64Value AS DWORD
                                           LOCAL zText AS ASCIIZ * 256
                                           Wow64DisableWow64FsRedirection(Wow64Value)
                                           zText = "osk.exe"
                                           ShellExecute (%NULL, "OPEN", zText, BYVAL %NULL, CURDIR$, %SW_SHOWNORMAL)
                                           Wow64RevertWow64FsRedirection(Wow64Value)  'required
                                          
                                          END FUNCTION
                                          https://www.tesla.com/roadster

                                          Comment

                                          Working...
                                          X