Help With Batch File

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
T_Arora
Posts: 3
Joined: 20 Jun 2012 03:51

Help With Batch File

#1 Post by T_Arora » 20 Jun 2012 04:03

I am trying to write a batch file that will take a version of Office XP and install another version.
I am able to do both.
My problem is that i dont what the installation to happen if the Uninstallation did not happen.
Pls let me know if their is a way to check if the command was successful.

The i am using is provided below:

\\ *Ms Office XP Unstallation Command Here*
@echo off
echo ................
timeout 120
cls
\\ *MS Office XP installation Command Here*
exit

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: Help With Batch File

#2 Post by Dos_Probie » 20 Jun 2012 04:42

normally office will just upgrade what you have, what version of office
are you uninstalling?, also ms has a officescrub.vbs file that you could call
from your batch then proceed with the new install ..

T_Arora
Posts: 3
Joined: 20 Jun 2012 03:51

Re: Help With Batch File

#3 Post by T_Arora » 20 Jun 2012 05:05

I am unstalling Office XP professional and installing Office XP standard version.
So I have to Unstall XP professional first.

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: Help With Batch File

#4 Post by foxidrive » 20 Jun 2012 05:37

Check if the installer or uninstaller returns an errorlevel result code.

You can then use the errorlevel to determine what to do.


uninstall command
if not errorlevel 1 (
install commands
)

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: Help With Batch File

#5 Post by Dos_Probie » 20 Jun 2012 06:17

Ok so you are doing a downgrade, have not used xp in years so cant vertify officexp registry location but
you could do the error level as suggested via a reg query as follows
Untested but you can get general idea

Code: Select all

@echo off
:Ck for O2Pro First
 reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%ProductName% 1>> "%LogLocation%\%computername%.txt" 2>>&1
 set Level=%ErrorLevel%
 echo Error Level=%Level%  >> "%LogLocation%\%computername%.txt"
 if %Level%==0 (goto End) else (goto OfficeStd)
 
REM If 1 returned, the product was not found. Run setup here.
 :OfficeStd
 "%DeployStd%\setup.exe" 1>> "%LogLocation%\%computername%.txt" 2>>&1
 echo %date% %time% Setup ended with error code %errorlevel%. >> "%LogLocation%\%computername%.txt"
 
REM If 0 or other was returned, the product was found or install was succesfull.
 :End

T_Arora
Posts: 3
Joined: 20 Jun 2012 03:51

Re: Help With Batch File

#6 Post by T_Arora » 20 Jun 2012 06:20

Thanks That works!

Squashman
Expert
Posts: 3739
Joined: 23 Dec 2011 13:59

Re: Help With Batch File

#7 Post by Squashman » 20 Jun 2012 06:40

You were able to uninstall a version of office and install a new version of office in 3 minutes flat?

Dos_Probie
Posts: 233
Joined: 21 Nov 2010 08:07
Location: At My Computer

Re: Help With Batch File

#8 Post by Dos_Probie » 20 Jun 2012 07:31

No Problem, just curious are you doing the Silent Install for Office Standard where its pre-activated etc.? 8)

Post Reply