none
Problem With File System Object and Shell Command RRS feed

  • Question

  • Access 2010
    Windows 10 Pro x64

    Trying to walk an entire disk and capture file sizes.
    Ran into a problem with a very long file name (which happened to be a URL).

    fso is a file system object
    ShellAndWait launches a shell command and waits for it to finish
    ShellAndWait is used where the file system object throws an error.  The command does a DIR of the file to a temporary file which is then parsed to get the file size.  In this case both the file system object and the shelled command fail.

    code:
      mrsFileNames.Fields("FileSize").Value = fso.GetFile(sPathFile).Size
                If (0 <> Err.Number) Then
                    lReturn = ShellAndWait("CMD /C ""DIR """ & vsPath & "\" & sFileName & """ > " & gsWorkFile & """", vbNormalFocus)
                    If (0 = lReturn) Then
                            ...
                        Else
                            MsgBox "Error[" & Hex$(Err.LastDllError) & "]: " & GetDllErrorMessage(Err.LastDllError)
                        End If

    sPathFile = "K:\VBoxBackup\VirtualBox\Users\Common\saberman\Favorites\Windows 10\https--social.technet.microsoft.com-Forums-en-US-ebc1410a-dbe4-4567-9add-e4ef5df24e38-what-happens-if-a-user-has-a-slideshow-setup-on-windows-81-with-selected-images-and-10-secondforum=win10itprosetup.url"

    The fso.GetFile(sPathFile).Size throws a File not found error.

    The command passed to ShellAndWait is:

    CMD /C "DIR "K:\VBoxBackup\VirtualBox\Users\Common\saberman\Favorites\Windows 10\https--social.technet.microsoft.com-Forums-en-US-ebc1410a-dbe4-4567-9add-e4ef5df24e38-what-happens-if-a-user-has-a-slideshow-setup-on-windows-81-with-selected-images-and-10-secondforum=win10itprosetup.url"

    The ShellAndWait returns a 1 and the error is:
    Error[5BF]: Unable to finish the requested operation because the specified process is not a GUI process.

    Any suggestions on how to troubleshoot this would be appreciated.

    http://www.saberman.com

    Sunday, August 13, 2017 5:13 AM

All replies

  • Hi saberman,

    I can see the file url file.

    I want to confirm with you that take the file path and paste in Windows Explorer.

    check whether it take you to the file location or not?

    you are getting file not found error.

    means it is possible that your file path is not correct.

    if it takes you to the file location then try to rename the file with some small name and again try to test with in your code .

    so that we can come to know that whether the problem is incorrect path name or long path name.

    let us know about your testing result. so that we can try to provide you further suggestions.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 14, 2017 2:35 AM
    Moderator
  • The file path is correct and I can access it explorer.  There are other url's in the folder that are processed correctly so it is probably the file name length.  It appears the file system object cannot handle it.

    What I don't understand is why the shell command fails -- especially with a GUI error.  If I open a cmd window and paste the command in it it works.


    http://www.saberman.com

    Monday, August 14, 2017 5:28 AM
  • Hi saberman,

    did you try to rename the file as I said before and try to test the same file again with in your code?

    if that work correctly , then I suggest you to limit the file name certain length.

    if you are generating the files using code then develop some logic in your code to format the file name.

    also in your code , you can try to check the length of the file name and if it is long then you can try to inform the user about this file and inform him to manually rename it and then try again.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Brook Kemp Monday, August 14, 2017 7:26 AM
    • Unproposed as answer by saberman Monday, August 14, 2017 7:43 AM
    Monday, August 14, 2017 6:17 AM
    Moderator
  • As I said there are other files in the same folder that are processed correctly so it is the file length causing the problem with the file system object.

    My question still is why does the shell command fail when the same command put into a cmd window works?


    http://www.saberman.com

    Monday, August 14, 2017 6:41 AM
  • Hi saberman,

    you had mentioned that,"My question still is why does the shell command fail when the same command put into a cmd window works?"

    this forum only handles the issues regarding VBA Access Object Model.

    so this forum does not provide any support for Shell command related question.

    there is a another MSDN forum which handles the Shell Command related issue.

    you can ask your question in that forum.

    so that you can get more accurate answer for your issue.

    Windows PowerShell Forum

    if you got the answer for your other question then I suggest you to mark the answer and close this thread before creating the new thread in that forum.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 14, 2017 6:57 AM
    Moderator
  • >this forum only handles the issues regarding VBA Access Object Model.

    >so this forum does not provide any support for Shell command related question.

    The Shell command is part of VBA and the Shell command launches the CMD module not the PowerShell module.

    It appears there is a bug in the VBA Shell command.  Can you confirm that?


    http://www.saberman.com

    Monday, August 14, 2017 7:20 AM
  • Hi saberman,

    you had mentioned that ,"It appears there is a bug in the VBA Shell command.  Can you confirm that?"

    No, I cannot confirm this.

    As I said, the focus of this forum is on Access Object model related issue.

    you are asking about Shell Command.

    so I suggested you to post the question where it belongs.

    they can make a test and can give you the answer.

    as you can see on that forum they only handles the Shell command related issues.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 14, 2017 8:12 AM
    Moderator
  • The forum you linked to is for the PowerShell scripting language.

    I repeat the Shell command is part of VBA and is therefore part of Access development.  It is defined in:
    VBA.Interaction.Shell

    Now if this forum does not handle VBA commands please point me to one that does and that is not the PowerShell forum.


    http://www.saberman.com

    Tuesday, August 15, 2017 2:25 AM
  • Hi saberman,

    you had mentioned that,"It is defined in: VBA.Interaction.Shell. Now if this forum does not handle VBA commands please point me to one that does and that is not the PowerShell forum."

    for VBA specific issue , the best suitable forum is below.

    Visual Basic for Applications (VBA) Forum

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, August 15, 2017 9:13 AM
    Moderator