Solved: How to write a batch file to amend a registry key??

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

lpool1

Thread Starter
Joined
Apr 15, 2010
Messages
9
Hi All,

Can any1 help me on writing a batch file for Windows XP which will amend the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\SafeMode\Components\DeskHtmlVersion

I have never written a batch file before, however I have had a try and it doesn't work. The details of my file are below:

REM -----Fix Active Desktop-----
Windows Registry Editor Version 5.00
regedit.exe /s "%USERPROFILE%\Desktop\Keith.reg"
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components]
"DeskHtmlVersion"=dword:00000000
"DeskHtmlMinorVersion"=dword:00000005
"Settings"=dword:00000001
"GeneralFlags"=dword:00000001


I need to change the value data in the key from Decimal 272 to 0.

Thanks,
lpool1
 
Joined
Jul 2, 2006
Messages
379
Hi,
The Windows Registry Editor Version 5.00 part is only needed if you are making a .reg file.
Try this instead:
Code:
REM -----Fix Active Desktop-----

reg add HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components /v DeskHtmlVersion /t REG_DWORD /d "WHATEVER YOU WANT TO CHANGE IT TO"
That will ask for confirmation to overwrite existing values, to skip that add /f to the end of reg add line.

Andy
 

lpool1

Thread Starter
Joined
Apr 15, 2010
Messages
9
Hi Andy,

I tried this and it said there are too many command line parameters :(. Any other suggestions?

Thanks,
Lpool1
 
Joined
Jul 2, 2006
Messages
379
Sorry, I completely forgot: The path to the registry key has to be in quotes if it has spaces :)

Andy
 

lpool1

Thread Starter
Joined
Apr 15, 2010
Messages
9
Thanks Andy,

This time it said the operation was completed successfully, however when I go into regedit and check the value, it still says 272. I think maybe the best thing is to test this on a PC which has the active desktop message.
 
Joined
Jul 2, 2006
Messages
379
Don't know if this will be the problem, but the code I wrote in my last post changed the value of DeskHtmlVersion in:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\

where you said you wanted to change it in:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\SafeMode\Components\

Change the path file in the bat file to that and it may do the trick
Just a thought :)
 

lpool1

Thread Starter
Joined
Apr 15, 2010
Messages
9
No the first one was actually correct. It just doesn't change the value :(.
 

lpool1

Thread Starter
Joined
Apr 15, 2010
Messages
9
yep, tried that. still the same. It is definately doing something cos it says operation successful. I just dont know what exactly.
 
Joined
Jul 2, 2006
Messages
379
What happens if you go into command prompt(Start>Run>cmd.exe) and type:
Code:
reg query "HKCU\Software\Microsoft\Internet Explorer\Desktop\Components"
What is the value for DeskHtmlVersion?
 

lpool1

Thread Starter
Joined
Apr 15, 2010
Messages
9
The following appeared:

! REG.EXE VERSION 3.0
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components
DeskHtmlVersion REG_DWORD 0x110
DeskHtmlMinorVersion REG_DWORD 0x5
Settings REG_DWORD 0x1
GeneralFlags REG_DWORD 0x1
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0
 
Joined
Aug 7, 2007
Messages
9,028
If you misplaced the end quote, or left it off, it won't change the value, but will instead add a new key
This will not work:
Code:
Reg Add "HKCU\Software\Microsoft\Internet Explorer\Desktop\Components /V DeskHtmlVersion /T REG_DWORD /D 0 /F[COLOR=Red][B]"[/B][/COLOR]
If you use that, it will add a new key named Components /V DeskHtmlVersion /T REG_DWORD /D 0 /F

It has to be like this:
Code:
Reg Add "HKCU\Software\Microsoft\Internet Explorer\Desktop\Components[COLOR=Red][B]"[/B][/COLOR] /V DeskHtmlVersion /T REG_DWORD /D 0 /F
Let's see if that's what happened.
Copy the text in the following code block into Notepad.
Save it on the desktop as Query.cmd. Be sure to change the Save as Type: box to All Files when saving.
Code:
[plain]Set _file=%userprofile%\Desktop\Query.txt
 >"%_file%" Echo.[CODE]
>>"%_file%" 2>&1 Reg Query "HKCU\Software\Microsoft\Internet Explorer\Desktop" /S
>>"%_file%" Echo.
Start Notepad "%_file%"
Exit[/plain][/code]Double click the file to run it. It will create a file named Query.txt on the Desktop and open it in Notepad. Copy and paste the text into your next reply.
 

lpool1

Thread Starter
Joined
Apr 15, 2010
Messages
9
I got the following:

Code:
! REG.EXE VERSION 3.0
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components
    DeskHtmlVersion REG_DWORD 0x110
    DeskHtmlMinorVersion REG_DWORD 0x5
    Settings REG_DWORD 0x1
    GeneralFlags REG_DWORD 0x1
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components\0
    Source REG_SZ About:Home
    SubscribedURL REG_SZ About:Home
    FriendlyName REG_SZ My Current Home Page
    Flags REG_DWORD 0x2
    Position REG_BINARY 2C0000002C01000000000000D4030000A2030000000000000100000001000000010000000000000000000000
    CurrentState REG_DWORD 0x40000004
    OriginalStateInfo REG_BINARY 18000000FFFF0000FFFF0000FFFFFFFFFFFFFFFF04000000
    RestoredStateInfo REG_BINARY 18000000D00300001F000000200100001601000001000000
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components /v DeskHtmlVersion /t REG_DWORD /d 0
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components /v DeskHtmlVersion /t REG_DWORD /d 0x00000000
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General
    BackupWallpaper REG_EXPAND_SZ 
    ComponentsPositioned REG_DWORD 0x1
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Old WorkAreas
    NoOfOldWorkAreas REG_DWORD 0x1
    OldWorkAreaRects REG_BINARY 000000000000000000050000A2030000
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\SafeMode
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\SafeMode\General
    Wallpaper REG_EXPAND_SZ %SystemRoot%\Web\SafeMode.htt
    VisitGallery REG_DWORD 0x0
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Scheme
    Edit REG_SZ 
    Display REG_SZ
 
Joined
Jul 2, 2006
Messages
379
That's whats happened isn't it! What the OutCaste said
Code:
reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\Components" /v DeskHtmlVersion /t REG_DWORD /d "0"
You want the closing quote mark where it is above, not at the very end of the line
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top