Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Olyrd
- Posts: 25
- Joined: 05 Feb 2016 07:36
#1
Post
by Olyrd » 10 Apr 2016 07:44
I'm trying to add a conext menu that will detele the selected folder's contents but I want to check if the current path is set to the selected folder first.
I've written the following but It doesn't work. It does change to the folder but doesn't delete anything.
Code: Select all
REG ADD "HKEY_CLASSES_ROOT\Directory\shell\Empty Directory\Command" /ve /d "cmd /c \"pushd %1 ^& if \"%cd%\"==%1 (del /s /f /q *.*)\"" /f
If I execute like this, the %cd% is replaced with cmd path, which I do not want.
I tried running it like this and still does not work:
Code: Select all
REG ADD "HKEY_CLASSES_ROOT\Directory\shell\Empty Directory\Command" /ve /d "cmd /c \"setlocal enabledelayedexpansion ^& pushd %1 ^& if \"!cd!\"==%1 (del /s /f /q *.*)\"" /f
Any insight? Thank you
-
aGerman
- Expert
- Posts: 4678
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 10 Apr 2016 09:21
Percent signs that you want to have parsed/passed literally have to be doubled.
Code: Select all
REG ADD "HKEY_CLASSES_ROOT\Directory\shell\Empty Directory\Command" /ve /d "%comspec% /c \"del /s /f /q \"%%1\*.*\"\"" /f