Home > database >  Windows Reg file seems to mess up the command syntax passed as default or special value to key
Windows Reg file seems to mess up the command syntax passed as default or special value to key

Time:02-05

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 ?

CodePudding user response:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\Shell\FolderName_Logs\command]
@="cmd /s /v /e /c set \"LogsDir=%           
  •  Tags:  
  • Related