My system is a 64 bit Windows 10 Pro running Microsoft Office 2013.
I have tried multiple methods excised from many website suggestions and all to no avail. I keep getting recurring errors. I begin with an inserted module of the sheet I want to contain the Form Control macro button in this xlsm file I am working with.
DeleteJunk.bat file as follows:
g:
rmdir Testing
To get this all to work for now I am using an empty bogus folder named Testing.
Ultimately the folder which I want to remove is hidden and locked with the program Easy File Locker.
Running the bat file outside Excel works fine to remove this hidden and locked folder.
Here then is a bit of up front information to help the viewer of this post to understand the what and why.
The xlsm file is a file my wife will open when I kick the bucket, when I buy the farm, when it is time for my dirt nap, etcetera. She is not Excel proficient in the least, but she is smart enough to pick a button that says “Upon Dwight’s Death Select This Button Before You Proceed To Do Anything.” This xlsm file is all the things she must do when I am pushing up daisies. She will not understand to go to a directory where the bat file exists and double click it to run it. She is very PC deficient.
Here then are the many VBA code scenarios I have tried:
Sub delete_folder()

Dim folder As Object
Dim path As String
path = (“G:\Testing”)
Set folder = CreateObject(“scripting.filesystemobject”)

folder.deletefolder path, True

End Sub

Private Sub delete_folder2()
Shell “cmd.exe /c cd “ & “F:\Dwight\In The Event Of My Death” & “ && runDeleteJunk.bat”
End Sub


ChDrive “F”
ChDir “F:\Dwight\In The Event Of My Death\”
Call Shell “F:\Dwight\In The Event Of My Death\DeleteJunk.bat”
End Sub


Shell (“F:\Dwight\In The Event Of My Death\DeleteJunk.bat”, vbHide)

Shell (“F:\Dwight\In The Event Of My Death\DeleteJunk.bat”, vbNormalFocus)


Sub DeleteJunk()
Call Shell(“CMD.EXE /C “ & “F:\Dwight\In The Event Of My Death\DeleteJunk.bat”)
End Sub


Sub openBatch()
Dim file_path As String
file_path = “G:\DeleteJunk.bat”
Call Shell(file_path, vbNormalFocus)

End Sub

Dim folderPath As String
Dim shellCommand As String

folderPath = Application.ActiveWorkbook.Path
shellCommand = """" & folderPath & "" & " DeleteJunk.bat" & """"
Call Shell(shellCommand, vbNormalFocus)



Sub DeleteJunk()

Dim folderPath As String
Dim shellCommand As String

folderPath = "F:\Dwight\In The Event Of My Death"
shellCommand = """" & folderPath & "" & " DeleteJunk.bat" & """"
Call Shell(shellCommand, vbNormalFocus)

End Sub



Sub ExecuteBATfile()
Shell “cmd.exe /k cd ” & ThisWorkbook.Path & “&&RunMe.bat”
End Sub


Sub openBatch()
Call Shell("""G:\DeleteJunk.bat""", vbNormalFocus)
End Sub

Sub openBatch()
Call Shell("""G:\DeleteJunk.bat""", vbHide)
End Sub

In all cases depending on the specific code I get one of the following errors:
Tried to insert images here but the "Manage Attachments" app was giving problems.

In all cases when I select Debug then the line that is similar to what you see in yellow is what I get.
Again, this line you see in yellow is the same line but depending on the code exactly what it states.
Tried to insert images here but the "Manage Attachments" app was giving problems.

So if someone needs to see the images I have available to insert then the first thing that needs to happen is the app needs to clear out incorrect images that persist even after an hour of time hence my first attempt at using this app more than an hour ago. The second thing that needs to happen is for the app to work as needed. I noticed there is no way for the user to delete incorrect images, not good!