I am trying to create a .reg file which can be imported in any Windows 7-10 system which after imported, provides a context-menu option to confirm with User whether to delete logs in a specific directory and then open that same directory in Explorer.
Now the .reg file I have created apparently looks correct syntax wise and it also opens the CMD prompt, but it doesn't execute the commands due to error.
Here's that .reg file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\FolderName_Logs]
@="Open folder-name's Logs"
[HKEY_CLASSES_ROOT\Directory\Background\shell\FolderName_Logs\command]
@="cmd /s /v /e /k \"set \"\"LogsDir=C:\\projects\\folder-name\\storage\\logs\"\" && if exist \"\"!LogsDir!\"\" (set /p ch=\"\"Delete Logs? \"\" && if /i !ch! equ 'y' del /f /s /q \"\"!LogsDir!\\*.log\"\") && start \"\"\"\" \"\"!LogsDir!\"\"\""
Is there any syntax trait/error that I missed here ? How to make this working ?
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\Shell\FolderName_Logs\command]
@="cmd /s /v /e /c set \"LogsDir=%%cd%%\" && if exist \"!LogsDir!\" (set /p ch=\"Delete Logs?\" && if /i '!ch!' equ 'y' del /f /s /q \"!LogsDir!\\*.log\") && start \"\" \"!LogsDir!\""
Note: I changed your hardcoded path to %CD% so it uses the directory you are in.