PC Review


Reply
Thread Tools Rate Thread

Changes to registry using a batch file

 
 
Patrick
Guest
Posts: n/a
 
      9th Apr 2009
Hello,

I am trying to modify the following key from:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"SourcePath"="F:\I386"

to:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"SourcePath"="C:\I386"

using a batch file with the "REG import" command to call a .reg file.
If I launch the batch file in a command prompt I get "The operation
completed successfully". But after I check regedit the changes were
not made. I

f I double click on the reg file and click on yes the changes are
made.

Your help is greatly appreciated
 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a
 
      9th Apr 2009

"Patrick" <(E-Mail Removed)> wrote in message
news:5df7e0a0-5ef5-4063-a550-(E-Mail Removed)...
> Hello,
>
> I am trying to modify the following key from:
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> "SourcePath"="F:\I386"
>
> to:
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> "SourcePath"="C:\I386"
>
> using a batch file with the "REG import" command to call a .reg file.
> If I launch the batch file in a command prompt I get "The operation
> completed successfully". But after I check regedit the changes were
> not made. I
>
> f I double click on the reg file and click on yes the changes are
> made.
>
> Your help is greatly appreciated


Let's have a look at your batch file and your .reg file.


 
Reply With Quote
 
Jon Wallace
Guest
Posts: n/a
 
      9th Apr 2009

Hey Patrick,

A couple of things...

This might sound like a silly question but are you refreshing (F5) your
REGEDIT view when you have run your batch file. To see the change you
typically have to refresh if you already have REGEDIT open and at the key...

Secondly, rather than maintaining a seperate .REG file, you can use the
following command to achieve what you want - it's a bit cleaner -

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v SourcePath /t
REG_SZ /d "C:\I386" /f

Hope this helps,
Jon

www.insidetheregistry.com

--

"Patrick" <(E-Mail Removed)> wrote in message
news:5df7e0a0-5ef5-4063-a550-(E-Mail Removed)...
> Hello,
>
> I am trying to modify the following key from:
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> "SourcePath"="F:\I386"
>
> to:
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> "SourcePath"="C:\I386"
>
> using a batch file with the "REG import" command to call a .reg file.
> If I launch the batch file in a command prompt I get "The operation
> completed successfully". But after I check regedit the changes were
> not made. I
>
> f I double click on the reg file and click on yes the changes are
> made.
>
> Your help is greatly appreciated


 
Reply With Quote
 
Patrick
Guest
Posts: n/a
 
      9th Apr 2009
The batch file is :

REG import \\orion\Install\Programs\Microsoft\SNMP\path.reg
REG import \\orion\Install\Programs\Microsoft\SNMP\root.reg

First .REG file is:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"SourcePath"="C:\I386"

and second .REG is

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
"SourcePath"="C:\"

Thank you

On Apr 9, 7:10*pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "Patrick" <patrickchkai...@gmail.com> wrote in message
>
> news:5df7e0a0-5ef5-4063-a550-(E-Mail Removed)...
>
>
>
>
>
> > Hello,

>
> > I am trying to modify the following key from:

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> > "SourcePath"="F:\I386"

>
> > to:

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> > "SourcePath"="C:\I386"

>
> > using a batch file with the "REG import" command to call a .reg file.
> > If I launch the batch file in a command prompt I get "The operation
> > completed successfully". But after I check regedit the changes were
> > not made. I

>
> > f I double click on the reg file and click on yes the changes are
> > made.

>
> > Your help is greatly appreciated

>
> Let's have a look at your batch file and your .reg file.- Hide quoted text -
>
> - Show quoted text -


 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      9th Apr 2009

"Patrick" <(E-Mail Removed)> wrote in message
news:8f9c54e3-f3cf-460c-9d10-(E-Mail Removed)...
The batch file is :

REG import \\orion\Install\Programs\Microsoft\SNMP\path.reg
REG import \\orion\Install\Programs\Microsoft\SNMP\root.reg

First .REG file is:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"SourcePath"="C:\I386"

and second .REG is

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
"SourcePath"="C:\"

Thank you

===================

There is a simple but highly effective method to solve such problems: You
use the "reg export" function to see what the format should look like, then
you apply the same rules to your own import. If you did this then you would
immediately see that you must double all back-slashes.


 
Reply With Quote
 
Patrick
Guest
Posts: n/a
 
      9th Apr 2009
On Apr 9, 7:12*pm, "Jon Wallace" <i...@insidetheregistry.com> wrote:
> Hey Patrick,
>
> A couple of things...
>
> This might sound like a silly question but are you refreshing (F5) your
> REGEDIT view when you have run your batch file. *To see the change you
> typically have to refresh if you already have REGEDIT open and at the key....
>
> Secondly, rather than maintaining a seperate .REG file, you can use the
> following command to achieve what you want - it's a bit cleaner -
>
> REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v SourcePath/t
> REG_SZ /d "C:\I386" /f
>
> Hope this helps,
> Jon
>
> www.insidetheregistry.com
>
> --
>
> "Patrick" <patrickchkai...@gmail.com> wrote in message
>
> news:5df7e0a0-5ef5-4063-a550-(E-Mail Removed)...
>
>
>
> > Hello,

>
> > I am trying to modify the following key from:

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> > "SourcePath"="F:\I386"

>
> > to:

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> > "SourcePath"="C:\I386"

>
> > using a batch file with the "REG import" command to call a .reg file.
> > If I launch the batch file in a command prompt I get "The operation
> > completed successfully". But after I check regedit the changes were
> > not made. I

>
> > f I double click on the reg file and click on yes the changes are
> > made.

>
> > Your help is greatly appreciated


Hi John,

I did refresh I even restarted the machine but not changes. Would the
add command work even if the key is already created?

Regards
 
Reply With Quote
 
Patrick
Guest
Posts: n/a
 
      9th Apr 2009
On Apr 9, 8:10*pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "Patrick" <patrickchkai...@gmail.com> wrote in message
>
> news:8f9c54e3-f3cf-460c-9d10-(E-Mail Removed)...
> The batch file is :
>
> REG import \\orion\Install\Programs\Microsoft\SNMP\path.reg
> REG import \\orion\Install\Programs\Microsoft\SNMP\root.reg
>
> First .REG file is:
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> "SourcePath"="C:\I386"
>
> and second .REG is
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
> "SourcePath"="C:\"
>
> Thank you
>
> ===================
>
> There is a simple but highly effective method to solve such problems: You
> use the "reg export" function to see what the format should look like, then
> you apply the same rules to your own import. If you did this then you would
> immediately see that you must double all back-slashes.


Actually I did that and the reg entry contained the double
backslashes, but I removed them when it did not work just to test it.
Sorry I copied the modified reg file. But the weird thing is if I use
the reg import command in the batch file "with the double back slash"
it doesn't work but when I double click on the reg file and click on
Yes it works.
 
Reply With Quote
 
Jon Wallace
Guest
Posts: n/a
 
      9th Apr 2009
Yes... that's what the /f switch is for at the end of it - to force
overwrite without prompt...

Do a REG ADD /? in the command prompt to see the full syntax...

Hope this helps,
Jon

www.insidetheregistry.com

---

"Patrick" <(E-Mail Removed)> wrote in message
news:1b40878a-14d3-4b5d-b447-(E-Mail Removed)...
On Apr 9, 7:12 pm, "Jon Wallace" <i...@insidetheregistry.com> wrote:
> Hey Patrick,
>
> A couple of things...
>
> This might sound like a silly question but are you refreshing (F5) your
> REGEDIT view when you have run your batch file. To see the change you
> typically have to refresh if you already have REGEDIT open and at the
> key...
>
> Secondly, rather than maintaining a seperate .REG file, you can use the
> following command to achieve what you want - it's a bit cleaner -
>
> REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v SourcePath
> /t
> REG_SZ /d "C:\I386" /f
>
> Hope this helps,
> Jon
>
> www.insidetheregistry.com
>
> --
>
> "Patrick" <patrickchkai...@gmail.com> wrote in message
>
> news:5df7e0a0-5ef5-4063-a550-(E-Mail Removed)...
>
>
>
> > Hello,

>
> > I am trying to modify the following key from:

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> > "SourcePath"="F:\I386"

>
> > to:

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> > "SourcePath"="C:\I386"

>
> > using a batch file with the "REG import" command to call a .reg file.
> > If I launch the batch file in a command prompt I get "The operation
> > completed successfully". But after I check regedit the changes were
> > not made. I

>
> > f I double click on the reg file and click on yes the changes are
> > made.

>
> > Your help is greatly appreciated


Hi John,

I did refresh I even restarted the machine but not changes. Would the
add command work even if the key is already created?

Regards

 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      9th Apr 2009

"Patrick" <(E-Mail Removed)> wrote in message
news:122cd046-27be-44a6-bd6e-(E-Mail Removed)...
On Apr 9, 8:10 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "Patrick" <patrickchkai...@gmail.com> wrote in message
>
> news:8f9c54e3-f3cf-460c-9d10-(E-Mail Removed)...
> The batch file is :
>
> REG import \\orion\Install\Programs\Microsoft\SNMP\path.reg
> REG import \\orion\Install\Programs\Microsoft\SNMP\root.reg
>
> First .REG file is:
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> "SourcePath"="C:\I386"
>
> and second .REG is
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
> "SourcePath"="C:\"
>
> Thank you
>
> ===================
>
> There is a simple but highly effective method to solve such problems: You
> use the "reg export" function to see what the format should look like,
> then
> you apply the same rules to your own import. If you did this then you
> would
> immediately see that you must double all back-slashes.


Actually I did that and the reg entry contained the double
backslashes, but I removed them when it did not work just to test it.
Sorry I copied the modified reg file. But the weird thing is if I use
the reg import command in the batch file "with the double back slash"
it doesn't work but when I double click on the reg file and click on
Yes it works.

===================

I strongly disagree. I tested your command before posting my reply and it
behaved as expected. I think you're not reporting everything you do or see,
same as you did not report the double backslash issue in your original post.


 
Reply With Quote
 
Patrick
Guest
Posts: n/a
 
      9th Apr 2009
On Apr 9, 10:21*pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "Patrick" <patrickchkai...@gmail.com> wrote in message
>
> news:122cd046-27be-44a6-bd6e-(E-Mail Removed)...
> On Apr 9, 8:10 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
>
>
>
>
>
> > "Patrick" <patrickchkai...@gmail.com> wrote in message

>
> >news:8f9c54e3-f3cf-460c-9d10-(E-Mail Removed)....
> > The batch file is :

>
> > REG import \\orion\Install\Programs\Microsoft\SNMP\path.reg
> > REG import \\orion\Install\Programs\Microsoft\SNMP\root.reg

>
> > First .REG file is:

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
> > "SourcePath"="C:\I386"

>
> > and second .REG is

>
> > [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
> > "SourcePath"="C:\"

>
> > Thank you

>
> > ===================

>
> > There is a simple but highly effective method to solve such problems: You
> > use the "reg export" function to see what the format should look like,
> > then
> > you apply the same rules to your own import. If you did this then you
> > would
> > immediately see that you must double all back-slashes.

>
> Actually I did that and the reg entry contained the double
> backslashes, but I removed them when it did not work just to test it.
> Sorry I copied the modified reg file. But the weird thing is if I use
> the reg import command in the batch file "with the double back slash"
> it doesn't work but when I double click on the reg file and click on
> Yes it works.
>
> ===================
>
> I strongly disagree. I tested your command before posting my reply and it
> behaved as expected. I think you're not reporting everything you do or see,
> same as you did not report the double backslash issue in your original post.


It's up to you to believe what you want, I have nothing to hide as I
want to solve this issue. Btw I agree with you that this command
should work since have another batch file which modify an entry in the
HKEY_Classes and it works perfectly it's just this one that is not
working eventhough I receive "The operation
completed successfully" but no changes.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch file, Registry Modification. =?Utf-8?B?UmFuZHkgVGVtcGxl?= Windows XP Security 3 9th Sep 2005 04:57 PM
Replace a registry key with a batch file? Jim Windows XP Basics 5 23rd Nov 2004 10:34 PM
How to Uncheck File and Printer sharing via registry or batch file? USP Windows XP Setup 0 16th Dec 2003 05:27 AM
Batch file to delete a registry key Larry Microsoft Windows 2000 Registry 3 21st Aug 2003 08:30 PM
Batch file to delete a registry key Larry Microsoft Windows 2000 Registry Archive 6 21st Aug 2003 08:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:02 PM.