Solved

registry script

Posted on 2004-08-03
13
3,427 Views
Last Modified: 2008-02-01
Hi experts,
i want to edit a reg value via batch, but this is a bit strange.
the registry path is: HKCR\JPEGFILE\SHELL\OPEN\COMMAND
this key contains a key named (Standart). And this key shell have the value: C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe

i tried following code:
C:\TEMP\SUPPORT\REG.EXE UPDATE "HKCR\JPEGFILE\SHELL\OPEN\COMMAND\(Standart)=C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe"
but this doesnt work!!! What could be the problem, or how must be the code???

thx mero
0
Comment
Question by:merowinger
  • 4
  • 2
  • 2
  • +4
13 Comments
 
LVL 5

Expert Comment

by:Luniz2k1
ID: 11703868
Try the following:

REG.EXE UPDATE "HKCR\JPEGFILE\SHELL\OPEN\COMMAND\(Standart)"="C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe"
0
 
LVL 31

Author Comment

by:merowinger
ID: 11704000
no sorry there appears a message:
update cannot import. error opening the file. possible causes is a disk error

mero
0
 
LVL 5

Expert Comment

by:Luniz2k1
ID: 11704069
I just created the string HKCR\JPEGFILE\SHELL\OPEN\COMMAND\(Standart) and ran:

REG.EXE UPDATE "HKCR\JPEGFILE\SHELL\OPEN\COMMAND\(Standart)"="C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe"

and it works just fine.

C:\>REG.EXE UPDATE "HKCR\JPEGFILE\SHELL\OPEN\COMMAND\(Standart)"="C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe"
The operation completed successfully.
0
 
LVL 31

Author Comment

by:merowinger
ID: 11704131
ok, i try it easier!!!
if i delete the "command" key and create it new, it contains a key named (standard). this is a reg_sz. and this key shell have the value C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe

but this silly ( ) arrrhhh!!!!
how do this with batch?? this i have!!!

C:\TEMP\SUPPORT\REG.EXE DELETE "HKCR\JPEGFILE\SHELL\OPEN\COMMAND" /FORCE
C:\TEMP\SUPPORT\REG.EXE ADD      "HKCR\JPEGFILE\SHELL\OPEN\COMMAND .........................= C:\...\PhotoEd.exe"
or
C:\TEMP\SUPPORT\REG.EXE ADD      "HKCR\JPEGFILE\SHELL\OPEN\COMMAND\(STANDARD) .........................= C:\...\PhotoEd.exe"
or...

mero
0
 
LVL 20

Expert Comment

by:Debsyl99
ID: 11704553
Hi

Are you trying to deploy this using logon scripts for example? Well just in case you are:

I tried this and it worked when I wanted to change a registry key on all pc's to point to a mapped drive for default workgroups for templates in word. Different scenario but principle should work the same,

Created a folder on the server to which i saved a .reg file containing the key change called yourregchange.reg: (set correct access permissions for authenticated users ie read/read and execute.

ie Windows Registry Editor Version 5.00

valid registry key and values


The login script batch file contained:

net use r: \\yourserver\RegChanges
regedit.exe /s r:\yourregchange.reg    
net use r: /delete

Hope this helps, and if I miss the point, forgive me!

Deb :))



0
 
LVL 3

Expert Comment

by:StGoY
ID: 11705271
Why would you map a network drive for a single reg file?
That's what NETLOGON is for! ;)

\\Youservername\Netlogon

Input this into a file caled Jpeg.reg :

    [HKEY_CLASSES_ROOT\jpegfile\shell\open\command]
    @="C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe"

Then, in your batch file, include this line :

    regedit /s %logonserver%\NETLOGON\Jpeg.reg

Basicly the same this as Deb, with some specifications! ;)

Steph
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 20

Expert Comment

by:Debsyl99
ID: 11705647
Why would you map a network drive for a single reg file?

Just my way as I will need to deploy numerous reg fixes from time to time to various pc's and swap the reg files in and of the mapped folder as necessary then use group policy to deploy it rather than netlogon. Saves having to change the login script on all my users and enables me to keep track of what's where.

Deb :))
0
 
LVL 31

Author Comment

by:merowinger
ID: 11706816
hi,
i'm not searching for the kind to execute else for the code

mero
0
 
LVL 3

Expert Comment

by:StGoY
ID: 11707418
I'm sorry, what?

That didn't quite make sense mero... you're not lookinh for a kind to execute else ?!?

Could ou rephrase that? ;)
0
 
LVL 31

Author Comment

by:merowinger
ID: 11712880
HI,

i want these key:  "HKCR\JPEGFILE\SHELL\OPEN\COMMAND\(Standard) <--
give a value, but my pc says that he cannot find the specified key, but it exists.

manuel i can give these key a value without problems, but i want to solve this via batch!!!
help!!!
mero

P.S. Sorry for my english!!!
0
 
LVL 10

Expert Comment

by:dis1931
ID: 11715071
You can create a regfile with notepad.  Just make sure it has a .reg extension.
 
Include Everything Between the dashed lines in the file------------------------------------------------------------------

Windows Registry Editor Version 5.00

[HKCR\JPEGFILE\SHELL\OPEN\COMMAND]
"Standard"="C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe"

--------------------------------------------------------------------------------------------------------------------------------

Then once you save it just double click on the file and it should merge it into the registry.  Just make sure the key/string/data name are all correct if not you will get errors such as "cannot find the specified key"  I suggest going to the location manually in the registry and then clicking on the key on the left side of regedit and clicking on copy key name.  This will copy it exactly as it appears in the registry.

Dis
0
 

Expert Comment

by:spinewr
ID: 11716604
Hello,

Everyone above is pretty correct. The best way to achieve your change is to use the export feature within the Registry Editor. You stated that you can make the change manually.  I am assuming that you can type the command in a dos window and it works fine.  I am also assuming that you are running your batch on your local machine to test and make sure it works first:

Better solution: Run Regedit, navigate to the key you wish to change, export it to a .reg file.
This file can be run from anywhere, locally or networked on various Windows platforms.  You can even call this within your batch file.  The only problem you would run into is if you are using variables in your batch file for the values/keys/data being entered into the registry.  If the key contains other information necessary for your needs, when you export you will receive whatever is in the key.

Special Note: Sometimes running batch based changes work great until you start working with locked down systems, where the end user may not be an administrator of the system.

Let me know how it goes!

Chow!
0
 
LVL 1

Accepted Solution

by:
asafganot earned 500 total points
ID: 11739979
You could use a vbs:

1. Create a new text file and paste the following:

set wshshell = createobject("wscript.shell")
      regkey = "HKCR\JPEGFILE\SHELL\OPEN\COMMAND\(Standart)"
                regval = C:\Programme\Gemeinsame Dateien\Microsoft Shared\PhotoEd\PhotoEd.exe
      wshshell.regwrite regkey ,regval
SET WSHSHELL = NOTHING

2. Save the file in a common location.
3. Rename it to name.vbs.
4. update your batch file with the following command:
cscript <network path\name.vbs>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Often we come across situations wherein our batch files would be needing to reboot Windows for a variety of reasons. A few of them would be like: (1) Setup files have been updated whose changes can take effect only after a reboot …
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now