Why does this not work

Page 6 of 7 FirstFirst ... 4567 LastLast

  1. Posts : 11,362
    Windows 10 Home x64 Version 21H2 Build 19044.1706
       #51

    Edwin,

    Thanks. I had not noticed that.

    Denis
      My Computer


  2. Posts : 13,934
    Windows 10 Pro X64 21H1 19043.1503
    Thread Starter
       #52

    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.
      My Computers


  3. Posts : 13,934
    Windows 10 Pro X64 21H1 19043.1503
    Thread Starter
       #53

    There's two, but when it runs you only see one. Look at the source code above it.
      My Computers


  4. Posts : 11,362
    Windows 10 Home x64 Version 21H2 Build 19044.1706
       #54

    Rich,

    "%%V" seems out of place. There is no variable called V and there is no For loop to require %%.

    Denis
      My Computer


  5. Posts : 889
    W10-2009 19042.1348
       #55

    I don't know what the problem is, but he sends %%V in order to get %V in the output (and succeeds).
      My Computer


  6. Posts : 7,456
    Windows 10 Home 20H2
       #56

    Ztruker said:
    First line works, second line fails with a syntax error.
    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>
      My Computer


  7. Posts : 13,934
    Windows 10 Pro X64 21H1 19043.1503
    Thread Starter
       #57

    Thank you Matthew, that works.

    Why does this not work-image.png

    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

    Why does this not work-image.png

    Edit: Okay, the new batch file is in-place, works great. Thanks again Matthew.
    Last edited by Ztruker; 01 Oct 2020 at 20:16.
      My Computers


  8. Posts : 13,934
    Windows 10 Pro X64 21H1 19043.1503
    Thread Starter
       #58

    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
      My Computers


  9. Posts : 7,456
    Windows 10 Home 20H2
       #59

    """"%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"
      My Computer


  10. Posts : 13,934
    Windows 10 Pro X64 21H1 19043.1503
    Thread Starter
       #60

    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?
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 07:19.
Find Us




Windows 10 Forums