Avatar of samiam41
samiam41
Flag for United States of America asked on

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.
Windows XPWindows Server 2003Shell Scripting

Avatar of undefined
Last Comment
samiam41

8/22/2022 - Mon
athomsfere

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.
SOLUTION
Justin Owens

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
samiam41

ASKER
@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?
samiam41

ASKER
I ask because there are several mods to the registry I need to make following the Office 2007 install.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Justin Owens

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
samiam41

ASKER
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.
Justin Owens

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Qlemo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
samiam41

ASKER
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

Justin Owens

Qlemo,

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

Justin
Qlemo

Samiam,
That should do. You can remove the part starting with ||, since you do nothing in case the key is not found (anymore).
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
samiam41

ASKER
Thanks everyone.  Wrapping this question up in the morning.  I appreciate your patience and help with this.
samiam41

ASKER
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.  
samiam41

ASKER
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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
samiam41

ASKER
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.

https://www.experts-exchange.com/questions/26787868/mod-registry-if-particular-key-exists.html

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

Thanks experts!
samiam41

ASKER
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.

https://www.experts-exchange.com/questions/26970766/reg-query-command-for-registry-entry.html?anchorAnswerId=35461977#a35461977