# [SOLVED] Batch file to change registry string value data



## kwarren (May 5, 2010)

I have a batch file that creates a registry key and a string. I want the string value data field to contain a path to a folder on the local machine but have been unsuccessful at doing so.
My current batch file contains the following: (This example does create the string but leaves the value data field blank)
--------------------------------------------------------------------------
@echo off

REM Add a registry key and values with Regedit.exe and a .reg file
REM /s is used to avoid an "Are you sure" prompt

REM Create the Registry key

> "%temp%\globalconfig.reg" ECHO Windows Registry Editor Version 5.00
>> "%temp%\globalconfig.reg" ECHO.
>> "%temp%\globalconfig.reg" ECHO [HKEY_LOCAL_MACHINE\Software\iTALC Solutions\iTALC\path2]
>> "%temp%\globalconfig.reg" ECHO "globalconfig"=""

regedit.exe /s "%temp%\globalconfig.reg" 
--------------------------------------------------------------------------

The new string is “globalconfig.” The value data field of this string needs to contain the following path:
C:\Documents and Settings\All Users\Application Data\iTALC\globalconfig.xml

I am new to batch file creation so please give me the “for dummies” explanation. 

Thanks,
Kirk


----------



## TheOutcaste (Mar 19, 2009)

*Re: Batch file to change registry string value data*

Welcome to TSF!

You've set the *globalconfig* value equal to nothing:

```
"globalconfig"=[B]""[/B]
```
It should be this

```
"globalconfig"=[B]"C:\\Documents and Settings\\All Users\\Application Data\\iTALC\\globalconfig.xml"[/B]
```
The \ must be doubled as the \ is the escape character.

Rather than create a file to merge, be easier to just use *reg.exe*, only one line needed and no file to delete afterward:

```
Reg Add "HKLM\Software\iTALC Solutions\iTALC\path2" /V globalconfig /T REG_SZ /D "C:\Documents and Settings\All Users\Application Data\iTALC\globalconfig.xml" /F
```
Enter *reg /?* in a prompt for all the options


----------



## kwarren (May 5, 2010)

*Re: Batch file to change registry string value data*

Thank you so much!!! The reg.exe method was much easier...thanks for the tip.


----------



## TheOutcaste (Mar 19, 2009)

*Re: Batch file to change registry string value data*

You're Welcome!

If your issue has been resolved you can mark this thread Solved by using the Thread Tools at the Top Right of this thread (above the first post) :grin:

Jerry


----------



## leesy (May 10, 2010)

hi, TheOutcaste,

I can see you are quite good with .bat
Can you help me with this?
I need to change a REG_DWORD file from value 0 to 1.

Currently, this is what i have but it is not working
_____________________________
@echo off

Reg Add “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon” /V AllowMultipleTSSessions /t REG_DWORD /d 1 /f

pause
___________________________________

where is my mistake? thanks in advance


----------



## kwarren (May 5, 2010)

Leesy,

Your batch code is correct but I noticed I had to delete the quotation marks and re-add them when I created the batch file to test it. For some reason the quotation mark font looked different when I copied and pasted your code into notepad.

I hope this helped,

Kirk


----------



## TheOutcaste (Mar 19, 2009)

I think *kwarren* has it right, batch files don't like the "curly quotes"
(“”)
will only work with standard double quotes:
("")
They are seen as another character, not as quotes, and will give you an *invalid key name* error.

This can happen if you are using a word processor like Word or Word Perfect, instead of a plain text editor, like Notepad, Notepad++, Notetab, etc.


----------



## leesy (May 10, 2010)

Thanks Kwarren and TheOutcaste! It is working now


----------

