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.
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.
Answer:
/C – Run Command and then terminate
/K – Run Command and then return to the CMD prompt. This is useful for testing, to examine variables