Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

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


(!)

lpool1's Avatar
lpool1 lpool1 is offline
Computer Specs
Junior Member with 9 posts.
THREAD STARTER
 
Join Date: Apr 2010
Experience: Intermediate
15-Apr-2010, 09:30 AM #1
Question Solved: How to write a batch file to amend a registry key??
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
andythepandy's Avatar
andythepandy andythepandy is offline
Computer Specs
Member with 367 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
27-Apr-2010, 12:32 PM #2
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's Avatar
lpool1 lpool1 is offline
Computer Specs
Junior Member with 9 posts.
THREAD STARTER
 
Join Date: Apr 2010
Experience: Intermediate
28-Apr-2010, 02:13 AM #3
Hi Andy,

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

Thanks,
Lpool1
andythepandy's Avatar
andythepandy andythepandy is offline
Computer Specs
Member with 367 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
28-Apr-2010, 02:40 AM #4
Sorry, I completely forgot: The path to the registry key has to be in quotes if it has spaces

Andy
lpool1's Avatar
lpool1 lpool1 is offline
Computer Specs
Junior Member with 9 posts.
THREAD STARTER
 
Join Date: Apr 2010
Experience: Intermediate
28-Apr-2010, 03:50 AM #5
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.
andythepandy's Avatar
andythepandy andythepandy is offline
Computer Specs
Member with 367 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
28-Apr-2010, 05:21 AM #6
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's Avatar
lpool1 lpool1 is offline
Computer Specs
Junior Member with 9 posts.
THREAD STARTER
 
Join Date: Apr 2010
Experience: Intermediate
28-Apr-2010, 07:13 AM #7
No the first one was actually correct. It just doesn't change the value .
andythepandy's Avatar
andythepandy andythepandy is offline
Computer Specs
Member with 367 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
28-Apr-2010, 07:15 AM #8
Have you refreshed the regedit window with F5?
lpool1's Avatar
lpool1 lpool1 is offline
Computer Specs
Junior Member with 9 posts.
THREAD STARTER
 
Join Date: Apr 2010
Experience: Intermediate
28-Apr-2010, 09:24 AM #9
yep, tried that. still the same. It is definately doing something cos it says operation successful. I just dont know what exactly.
andythepandy's Avatar
andythepandy andythepandy is offline
Computer Specs
Member with 367 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
28-Apr-2010, 09:36 AM #10
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's Avatar
lpool1 lpool1 is offline
Computer Specs
Junior Member with 9 posts.
THREAD STARTER
 
Join Date: Apr 2010
Experience: Intermediate
28-Apr-2010, 10:52 AM #11
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
andythepandy's Avatar
andythepandy andythepandy is offline
Computer Specs
Member with 367 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
29-Apr-2010, 05:23 AM #12
Then I really don't have a clue what's happening and can't think of anything else to try!
Sorry!
TheOutcaste's Avatar
Computer Specs
Member with 9,028 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
29-Apr-2010, 08:01 AM #13
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"
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" /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:
Set _file=%userprofile%\Desktop\Query.txt
 >"%_file%" Echo.[CODE]
>>"%_file%" 2>&1 Reg Query "HKCU\Software\Microsoft\Internet Explorer\Desktop" /S
>>"%_file%" Echo.[/CODE]
Start Notepad "%_file%"
Exit
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's Avatar
lpool1 lpool1 is offline
Computer Specs
Junior Member with 9 posts.
THREAD STARTER
 
Join Date: Apr 2010
Experience: Intermediate
30-Apr-2010, 03:29 AM #14
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
andythepandy's Avatar
andythepandy andythepandy is offline
Computer Specs
Member with 367 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
30-Apr-2010, 03:33 AM #15
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
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


Tags
bat, batch file, xp batch file

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Title Thread Starter Forum Replies Last Post
Writing a batch file to control PowerISO mikejreading All Other Software 2 23-Sep-2009 10:06 PM
Solved: Batch file to concatenate then rename files nesr DOS/Other 7 21-Mar-2009 01:27 AM
Solved: Batch file to del *.txt files from a dir older than today odewallrus DOS/Other 8 24-Feb-2009 12:07 PM
how to create batch file for user login information bhanuk Windows XP 2 08-Jan-2009 07:29 AM
batch file to read from input file jpmg DOS/Other 6 30-Aug-2008 02:14 AM

WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑