New
#51
Edwin,
Thanks. I had not noticed that.
Denis
Old thread, spinning wheels:
Trying to get rid of a .reg file and instead use REG in a batch file to add registry data.
set batchfile=%userprofile%\GenFileList.bat
(REG Add "HKCR\AllFilesystemObjects\shell\printDir" /V "Create File List" /T REG_SZ /F)
(REG Add "HKCR\AllFilesystemObjects\shell\printDir\Command" /VE /D "%batchfile%" "%%V" /F)
First line works, second line fails with a syntax error.
Code:aaa C:\Users\ztruk>set batchfile=C:\Users\ztruk\GenFileList.bat C:\Users\ztruk>(REG Add "HKCR\AllFilesystemObjects\shell\printDir" /V "Create File List" /T REG_EXPAND_SZ /F ) The operation completed successfully. C:\Users\ztruk>(REG Add "HKCR\AllFilesystemObjects\shell\printDir\Command" /VE /D "C:\Users\ztruk\GenFileList.bat" "%V" /F ) ERROR: Invalid syntax. Type "REG ADD /?" for usage.
Rich,
"%%V" seems out of place. There is no variable called V and there is no For loop to require %%.
Denis
I don't know what the problem is, but he sends %%V in order to get %V in the output (and succeeds).
The following line contains no syntax error.
Code:(REG Add "HKCR\AllFilesystemObjects\shell\printDir\Command" /VE /D """"%batchfile%""" """%%V"""" /F)
See the output below:
Code:Microsoft Windows [Version 10.0.18362.1016] (c) 2019 Microsoft Corporation. All rights reserved. C:\Windows\system32>set batchfile=%userprofile%\GenFileList.bat C:\Windows\system32>(REG Add "HKCR\AllFilesystemObjects\shell\printDir\Command" /VE /D """"%batchfile%""" """%%V"""" /F) The operation completed successfully. C:\Windows\system32>
Thank you Matthew, that works.
Now Create File List from the File Explorer context menu works correctly as well.
Denis, %V is valid, same as %1: Windows Extension Specific Context Menu Modification
Edit: Okay, the new batch file is in-place, works great. Thanks again Matthew.
Last edited by Ztruker; 01 Oct 2020 at 20:16.
I don't understand how all the quotes get handled in this:
/D """"%batchfile%""" """%%V"""" /F
Is this what actually gets passed to REG?
/D ""C:\Users\ztruk\GenFileList.bat"" ""%V"" /F
""""%batchfile%""" """%V""""
My understanding is that the first and last quotation marks (shown in red) will be ignored.
A group of three quotation marks (shown in blue above) will be counted as a single quotation mark (shown in blue below) to be written into Registry.
"C:\Users\Matthew_Wai\GenFileList.bat" "%V"
That's is what ends up in the registry. I never have any luck trying to match up double quotes in batch file processing. I seem to always end up with too many or not enough.
Thank you.
Is there anywhere that describes this behavior?