• Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Author
    Topic
    #445980

    This command works at the command line and removes Streets and any sub direcrories
    rd “F:PropertiesStreets” /s /q

    I’m trying to run this command in VBA and getting rte 53 file not found on the following:

    Call Shell(stAppName, 1)

    Contents of stAppName is “rd F:PropertiesStreets /s /q”

    What is the proper syntax?

    Thanks, John

    Sub Remove_Property_Folders()
    
        ChDrive "F"             ' Make "F" the current drive.
        ChDir "F:Properties"     ' Change current directory or folder
        
        Dim stAppName As String
    
        stAppName = "rd F:PropertiesStreets /s /q"    'rd "F:PropertiesStreets" /s /q
        
        Call Shell(stAppName, 1)
        
        MkDir "Streets"         ' Make current directory or folder
        
    End Sub
    
    Viewing 0 reply threads
    Author
    Replies
    • #1082827

      rd is not an executable. Use this:

      stAppName = "cmd /c rd F:PropertiesStreets /s /q"

      cmd is the command processor cmd.exe.

      • #1082845

        Fantastic!

        The only way the following works is with msgbox bewteen calls. I think I have a timing issue.

        The folder is removed but not created without the msgbox

        Is there a way to do this without msgbox?

        Thanks, John

        Sub Remove_Make_Properties_Streets_Folders()
            
            Call Remove_Properties_Streets_Folders
        
            MsgBox "PropertiesStreets Removed"
            
            Call Make_Properties_Streest_Folder
        
        End Sub
        
        • #1082847

          You could try inserting a

          DoEvents

          or two.

          • #1082851

            10 DoEvents didn’t get it, the following seems to work:

            Thanks, John

                Dim I, OpenForms
                For I = 1 To 150000    ' Start loop.
                    If I Mod 1000 = 0 Then     ' If loop has repeated 1000 times.
                        OpenForms = DoEvents    ' Yield to operating system.
                    End If
                Next I    ' Increment loop counter.
            
    Viewing 0 reply threads
    Reply To: Problem With Shell Command? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: