Page 1 of 1
Simple Batch 'IF' script just cant get it working
#1
Posted 13 March 2009 - 05:37 PM
I know Im probably missing something very simple but Im amature when it comes to batch scripting. What I am trying to do is this. Remove symantec, Then check if sophos is installed (doing this by looking for a particular file in the sophos installation directory) if exists do nothing, if not exist then install.
%windir%\system32\msiexec.exe /q /x {76B2BC31-2D96-4170-9C44-09E13B5555F3} /norestart
IF EXIST ""C:\Program files\Sophos\savmain.exe" goto end
\\ln-co-avs01\InterChk\ESXP\setup.exe -mng yes -user domain\username -pwd Pass#123 -s
exit
i can get it to uninstall symantec and then install sophos but it keeps reinstalling sophos to a client that already has it installed.
your help would be greatly appreciated.
%windir%\system32\msiexec.exe /q /x {76B2BC31-2D96-4170-9C44-09E13B5555F3} /norestart
IF EXIST ""C:\Program files\Sophos\savmain.exe" goto end
\\ln-co-avs01\InterChk\ESXP\setup.exe -mng yes -user domain\username -pwd Pass#123 -s
exit
i can get it to uninstall symantec and then install sophos but it keeps reinstalling sophos to a client that already has it installed.
your help would be greatly appreciated.
#2
Posted 13 March 2009 - 08:04 PM
Cmd promt not my best but give this a try
Quote
@Echo Off
CLS
Color f5
Mode 62,7
Title Anti Virus Change Brand
Set Sophos="C:\Program files\Sophos\savmain.exe"
If Exist %Sophos% Goto Work1
If Not Exist %Sophos% Goto Work2
:Work1
CLS
Echo.
Echo Confirm %Sophos%
ping -n 3 127.0.0.1>nul
Goto TheEnd
:Work2
Cls
Echo.
Echo Preparing To Unistall Symantec
Start /W %windir%\system32\msiexec.exe /q /x {76B2BC31-2D96-4170-9C44-09E13B5555F3} /norestart
CLS
Echo.
Echo Preparing To Install Sophos
Start /W \\ln-co-avs01\InterChk\ESXP\setup.exe -mng yes -user domain\username -pwd Pass#123 -s
CLS
Echo.
Echo Completed Sophos Install
ping -n 3 127.0.0.1>nul
Goto TheEnd
:TheEnd
Exit
#3
Posted 14 March 2009 - 04:40 AM
Another option. Using CMD in WinNT based systems is safe to use multiline statements so this avoids the goto feature.
Using Start /Wait is another option that gunsmokingman mentions that could be needed though I test without first up to see if successful.
You can use the command 'If /?' at a command prompt to learn the usage of 'If'. 'Goto' is rather redundant in many of the latest programming languages so is perhaps good to avoid using if possible IMO unless you service 9x or earlier systems with scripts.
%systemroot%\system32\msiexec.exe /q /x {76B2BC31-2D96-4170-9C44-09E13B5555F3} /norestart
If Not Exist "%Programfiles%\Sophos\savmain.exe" (
\\ln-co-avs01\InterChk\ESXP\setup.exe -mng yes -user domain\username -pwd Pass#123 -s
)
Using Start /Wait is another option that gunsmokingman mentions that could be needed though I test without first up to see if successful.
You can use the command 'If /?' at a command prompt to learn the usage of 'If'. 'Goto' is rather redundant in many of the latest programming languages so is perhaps good to avoid using if possible IMO unless you service 9x or earlier systems with scripts.
#4
Posted 14 March 2009 - 05:53 AM
What about gettting rid of live update too!
MsiExec /norestart /q/x"{76B2BC31-2D96-4170-9C44-09E13B5555F3} REMOVE=ALL"
"%ProgramFiles%\Symantec\LiveUpdate\LSETUP.EXE" /U
#5
Posted 14 March 2009 - 08:21 AM
Hey Guys,
Thanks a ton for your replies and help. Especially to gunsmokingman. That worked perfectly! Yzowl, I added your line to remove liveupdate as well.
Thanks again guys for the quick and thorough explanations.
Thanks a ton for your replies and help. Especially to gunsmokingman. That worked perfectly! Yzowl, I added your line to remove liveupdate as well.
Thanks again guys for the quick and thorough explanations.
This post has been edited by a_user: 14 March 2009 - 08:40 AM
#6
Posted 14 March 2009 - 08:57 AM
You may wish to add the /q switch too:
MsiExec /norestart /q/x"{76B2BC31-2D96-4170-9C44-09E13B5555F3} REMOVE=ALL"
"%ProgramFiles%\Symantec\LiveUpdate\LSETUP.EXE" /U /q
BTW did you notice the REMOVE=ALL I added to your uninstallation command line!
#7
Posted 16 March 2009 - 01:26 PM
Yes thank you. Makes for a very clean removal. Again, appreciate all the help!
#8
Posted 02 October 2009 - 06:21 PM
Yzöwl, on Mar 14 2009, 09:57 AM, said:
You may wish to add the /q switch too:
MsiExec /norestart /q/x"{76B2BC31-2D96-4170-9C44-09E13B5555F3} REMOVE=ALL"
"%ProgramFiles%\Symantec\LiveUpdate\LSETUP.EXE" /U /q
BTW did you notice the REMOVE=ALL I added to your uninstallation command line!Pardon my ignorance. In the above example for removing live update, where should that be placed in the script?
Is it after %systemroot%\system32\msiexec.exe /q /x {123456} /norestart ?
Thank you in advance
#9
Posted 04 October 2009 - 08:16 AM
I'd suggest you remove LU after having removed the Symantec product(s), however it shouldn't be necessary.
#10
Posted 05 October 2009 - 10:47 AM
Thank you, Yzowl.
One more question: do I need the quoation marks in the below statement - e.g. " " ?
MsiExec /norestart /q/x"{76B2BC31-2D96-4170-9C44-09E13B5555F3} REMOVE=ALL"
"%ProgramFiles%\Symantec\LiveUpdate\LSETUP.EXE" /U /q
One more question: do I need the quoation marks in the below statement - e.g. " " ?
MsiExec /norestart /q/x"{76B2BC31-2D96-4170-9C44-09E13B5555F3} REMOVE=ALL"
"%ProgramFiles%\Symantec\LiveUpdate\LSETUP.EXE" /U /q
- ← Visual Studio 6 with SP6 slipstreamed? Possible?
- Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
- Environment variables →
Share this topic:
Page 1 of 1



Help
Back to top










