X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Delete Directory Rmdir /s /q -- .*.ini File Not Updated    
post Jan 28 2020, 11:55 PM

Posts: 564
Joined: 26-May 04
From: Annapolis, MD USA


How can the attributes: /S & /Q be added after the DOS command RmDir or RD in the code below?
/S: Delete all files and subfolders in addition to the folder itself. Use this to remove an entire folder tree.
/Q: Quiet - do not display Y/N confirmation

In the below code adding the /S and /Q attributes causes an error in VBA

Using a string, such as: & " /S /Q " & also does not work

Sub DeleteDir(sDir As String)

    On Error Resume Next
    Kill sDir & "*.*"   ' delete all files in the folder
    RmDir sDir          ' delete folder
    On Error GoTo 0
End Sub

I tried a "Command window" and sending the codes, but I could not get it to run.

I want to do this because sometimes the folder's *.ini file is not updated
and the file appears to exist in the directory, though it does not.

Any suggestions?

Thank you,
In Annapolis, MD
This post has been edited by jcorlando: Jan 29 2020, 12:00 AM
Go to the top of the page
post Jan 29 2020, 02:23 AM

Posts: 1,312
Joined: 25-January 16
From: The Great Land

AFAIK, VBA does not support switches. To remove subfolders review http://www.felicini.com/excel-vba/vba-deletefilesandfolders

Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    6th April 2020 - 05:41 AM