Reputation: 1577
Here is what I'm trying right now:
Sub del_BJSFM_files()
Call Shell("cmd.exe /S /K" & "cd /d C:\UTAS-SA && del /f/s/q BJSFM > nul", vbNormalFocus)
End Sub
The problem is that the command window stays open.
I tried removing the "/K" but then the command doesn't execute properly.
Upvotes: 5
Views: 20310
Reputation: 43585
/C - Run Command and then terminate
/K - Run Command and then return to the CMD prompt. This is useful for testing, to examine variables
Source - https://ss64.com/nt/cmd.html
Upvotes: 2
Reputation: 58
Here is code for it
Sub del_BJSFM_files()
Call Shell("cmd.exe /S /c" & "cd /d C:\UTAS-SA && del /f/s/q BJSFM > nul", vbNormalFocus)
End Sub
I replaced /k with /c and now it closes the window.
Upvotes: 3