Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write value to registry that has quotations

Status
Not open for further replies.
Mar 18, 2002
12
US
How can I write the following value to the registry:

cmd.exe /k \"cd %1\"

I am trying to write this to HKEY_CLASSES_ROOT\Directory\shell\Command\command\ but the bit in quotations is giving me problems. If I try
WshShell.RegWrite "HKEY_CLASSES_ROOT\Directory\shell\Command\command\", "cmd.exe /k \"cd %1\"" , "REG_SZ" I get an error message because of the two sets of double quotations. Using singles writes the value without error, but does not work.
 
Use Chr(34) instead of the quotation marks (the ascii number for ")

WshShell.RegWrite "HKEY_CLASSES_ROOT\Directory\shell\Command\command\", "cmd.exe /k \" & chr(34) & "cd %1\" & chr(34) , "REG_SZ"
 
or use two double quotes:

WshShell.RegWrite "HKEY_CLASSES_ROOT\Directory\shell\Command\command\", "cmd.exe /k \""cd %1\""" , "REG_SZ" Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top