• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 885
  • Last Modified:

login batch script to modify reg if certain reg file exist on pc

Hi Experts.  As I upgrade these Windows XP machines from Office 2003 to 2007, I need to modify the registry on the upgraded pc's.  I don't know the term to use for the login script to modify the registry only if the Office 12.0 reg entry is there.  This is what I have:

if exist "hkcu\software\microsoft\office\12.0"
reg delete HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run

I'm not sure how to specify what to do if that reg file does "not" exist.  How can I specify if exist, do A; if entry doesn't exist, do B?

Thanks in advance.
0
samiam41
Asked:
samiam41
  • 9
  • 4
  • 2
  • +1
2 Solutions
 
athomsfereCommented:
Is it a do nothing id does not exist?

Batch is different then a true language, where in VB or JS you would normally write something like:

If <condition> then {
do something
}
else {
Do nothing
}
end if

Batch, you can write:

If exist <value> do (<something>)

You are not required to write an else or else if, if nothing else is needed.
0
 
Justin OwensITIL Problem ManagerCommented:
In Batch, there is no "ELSE" in IF statements.  Your IF includes the selected parameters, and then it goes on.  If it doesn't meet the parameters, it just goes on.  You will need to manipulate it differently, though.  IF you want to check for the existence of a registry key and delete a specif key if it does exist, try this:

REG QUERY "HKCU\Software\Microsoft\Office\12.0" || REG DELETE "HKCU\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run"

Remember that the Registry is Case SeNsItIvE.  HKCU\Software is different than HKCU\software.  Additionally, I would avoid using an IF statement in dealing with registry manipulation.

Justin
0
 
samiam41Author Commented:
@athomsfere: thanks for the quick response and information/explanation.  

@drultima:  Great call on the reg query part.  I would have pulled out what remaining hair I had left on diagnosing why it wasn't running.  After reading the last line of your response, you would suggest modifying the registry differently than the way I had planned?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
samiam41Author Commented:
I ask because there are several mods to the registry I need to make following the Office 2007 install.
0
 
Justin OwensITIL Problem ManagerCommented:
Well, if you don't want to use VB, I would honestly write a batch file to run at the end of the upgrade to just delete the keys you are needing deleted rather than querying everything.  You know they will probably be there, right?

Justin
0
 
samiam41Author Commented:
The office 2007 deployment is being managed by LANguard and I don't see where I can configure a batch file to run following the deployment.
0
 
Justin OwensITIL Problem ManagerCommented:
I am unfamiliar with LANguard.  Could you use it to deploy a flag file (empty text file) to search for?  Then, you could use your IF EXIST clause to look for that text file (though, I would do a IF NOT EXIST "filename" GOTO END instead) and run your changes at that point.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
DrUltima,
In Batch, IF with ELSE is available:
if not exist ThisFile.Reg (echo yes) else (echo no)
or, if we have to check for the result of a command:
reg query HKCU\Software >nul 2>nul && (echo Key exists) || (echo Key not available)

samiam41,
I agree to the "brute force delete" method. I would just check for the First-Run key (similar to what DrUltima showed), and then do a lot of things:
2>nul >nul reg query "HKCU\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run" && (
  reg delete "HKCU\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run"
  reg delete ...
) || (
  REM anything to do if the key is already deleted, which usually is - nothing
)

Open in new window

0
 
samiam41Author Commented:
Thanks for the suggestions.  Great work!

Looking through LANguard, I don't see an option to run a batch file after the Office 2007 install is finished.  The best option I would have is to get the user when they log in.  That said, what would the portion of code look like that I would insert into the existing login script?  I added a couple lines of code representing registry entries that needed to be "added" as well.


2>nul >nul reg query "HKCU\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run" && (
  reg delete "HKCU\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run"
  reg delete "HKCU\Software\Microsoft\Office\12.0\Outlook\Setup\FirstRun"
  reg add "HKCU\Software\Microsoft\Office\12.0\Outlook\Setup" /v "ImportPRF" /d "\\w2k3nas01\public\office.2007\prf\cs.outlook07.PRF" /f
  reg add "HKCU\Software\Microsoft\Office\12.0\Common\General" /v "ShownOptIn" /t reg_dword /d 0x1 /f
  reg add "HKCU\Software\Microsoft\Office\12.0\Outlook\Search" /v "DisableDownloadSearchPrompt" /t reg_dword /d 0x1 /f
  reg add "HKCU\Software\Microsoft\Office\12.0\Outlook\Options\RSS" /v "SyncToSysCFL" /t reg_dword /d 0x0 /f
) || (
  REM anything to do if the key is already deleted, which usually is - nothing
) 

Open in new window

0
 
Justin OwensITIL Problem ManagerCommented:
Qlemo,

You are right.  It has been so long since I wrote anything in batch I am apparently getting rusty.  Thanks for clarifying.

Justin
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Samiam,
That should do. You can remove the part starting with ||, since you do nothing in case the key is not found (anymore).
0
 
samiam41Author Commented:
Thanks everyone.  Wrapping this question up in the morning.  I appreciate your patience and help with this.
0
 
samiam41Author Commented:
Ok.  I finally got the LANguard software working again after the app took an e-nap.  Now that the server (and software) are working, I will test this script out and if the e-Gods are willing, I should be able to close the question out and award points.  Thank you all for your help and patience.  
0
 
samiam41Author Commented:
Great work and thanks for the help!  Sorry it took so long to finish out but my appreciation remains.  I look forward to working with you all again!

Take care,
Aaron
0
 
samiam41Author Commented:
Hi everyone!  Hope the new year has started well for everyone.

if anyone is interested in earning some more points, I posted a question here.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_26787868.html

I created a new one instead of adding it on here since who doesn't like points for their hardwork?

Thanks experts!
0
 
samiam41Author Commented:
Hi again.  if anyone is looking to grab up 2000 points on an easy (easy meaning for you) question, please check out this link.  Thanks in advance.  Also, rather than reading through the entire question and thread, I wrote a summary of the question in the very last comment box.

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/XP/Q_26970766.html#a35461977
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now