Search code examples
windowsbatch-fileregistryregedit

Why wont this registry data value update?


I am writing a batch script to add a registry key default value but it wont write to the value. The value needs to be:

"C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" /dde "%1"

I think it has something to do with the quotation mark characters " " but cant figure out how to make the batch script understand this needs to be in the data value.

This is what I am using:

REG ADD HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\command /ve /d "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" /dde "%1" /f

Solution

  • REG ADD "HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\Open\command" /ve /d "\"C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE\" /dde \"%%1\"" /f
    

    You need to escape the inner quotes and the %1 that is replaced by the parser that sees it as the first argument to the batch file