Solved

Batch Script Help

Posted on 2014-02-14
2
493 Views
Last Modified: 2014-03-06
Hello,

Can someone please help me with a script please, I'm trying to uninstall system centre endpoint protection

which is achieved by the following:

Script Name: Uninstall Security Essentials
Script Description:

IF True
THEN
   Execute File - (Continue on Fail)
     Parameter 1 : %PROGRAMFILES%\Microsoft Security Client\setup.exe
     Parameter 2 : /x /s
     Parameter 3 : 3
         OS Type : 13
   Execute File - (Continue on Fail)
     Parameter 1 : %ProgramW6432%\Microsoft Security Client\setup.exe
     Parameter 2 : /x /s
     Parameter 3 : 3
         OS Type : 13
   Execute File - (Continue on Fail)
     Parameter 1 : %PROGRAMFILES%\Microsoft Security Essentials\setup.exe
     Parameter 2 : /x /s
     Parameter 3 : 3
         OS Type : 13
   Execute File - (Continue on Fail)
     Parameter 1 : %ProgramW6432%\\Microsoft Security Essentials\setup.exe
     Parameter 2 : /x /s
     Parameter 3 : 3
         OS Type : 13
ELSE

After that has completed I need a what if statement to determine if C:\windows\ccmsetup exists and if so to uninstall it by changing directory to c:\windows\ccmsetup and then c:\windows\ccmsetup\ccmsetup /uninstall.

This normally takes like 10 minutes to complete so if it's possible to pause the script for 10 minutes or so then I can use the my installation script to install Microsoft Intune but I'll also need a what if statement there too to check if this installation folder is present 'C:\Program Files\Microsoft\OnlineManagement' if so then ignore, if not install this by: browsing to a network share and an MSI file.

Can you assist?
0
Comment
Question by:ProjNet
2 Comments
 
LVL 29

Accepted Solution

by:
matrixnz earned 500 total points
ID: 39861209
Highly recommend using AutoIT instead of batch, just download AutoIT and the AutoIT Script Editor and copy and paste the code below, into the Editor and modify then simply Build your .exe file and test.

#NoTrayIcon

;~ Microsoft Security Essentials
;~ Checks to see if file setup.exe exists before executing
If FileExists(@ProgramFilesDir & '\Microsoft Security Essentials\setup.exe) Then
;~ Run Setup.exe and wait for process to close
  RunWait(@ProgramFilesDir & '\Microsoft Security Essentials\setup.exe -X /s', '', @SW_HIDE)
Else
	;~ If directory didn't exist, copy the contents from the server to the local machine
	$VAR_DIRCOPY = DirCopy('\\Server\Share\Microsoft_Security_Essentials', @ProgramFilesDir, 1)
	;~ If an error occurs during copying, create an error message and then exit, this is optional
	If $VAR_DIRCOPY = 0 Then
		MsgBox(32, 'Error:', 'Error copying Microsoft Security Essentials')
		Exit
	Else
		;~ Run Setup.exe and wait for process to close
		RunWait(@ProgramFilesDir & '\Microsoft Security Essentials\setup.exe -X /s', '', @SW_HIDE)
	EndIf
EndIf

;~ CCMSETUP Uninstall
;~ Check to see if file ccmsetup exists before executing uninstall
If FileExists(@WindowsDir & '\ccmsetup\ccmsetup.exe') Then
	RunWait(@WindowsDir & '\ccmsetup\ccmsetup.exe /uninstall', '', @SW_HIDE)
EndIf

;~ Microsoft Intune
 If FileExists(@ProgramFilesDir & '\Microsoft\OnlineManagement\Filename.msi') Then
	 RunWait(@SystemDir & '\msiexec /i "' & @ProgramFilesDir & '\Microsoft\OnlineManagement\Filename.msi" /qn /norestart', '', @SW_HIDE)
 Else
	;~ If directory didn't exist, copy the contents from the server to the local machine
	$VAR_DIRCOPY = DirCopy('\\Server\Share\OnlineManagement', @ProgramFilesDir & '\Microsoft\', 1)
	;~ If an error occurs during copying, create an error message and then exit, this is optional
	If $VAR_DIRCOPY = 0 Then
		MsgBox(32, 'Error:', 'Error copying Microsoft OnlineManagement')
		Exit
	Else
		;~ Run Setup.exe and wait for process to close
		RunWait(@SystemDir & '\msiexec /i "' & @ProgramFilesDir & '\Microsoft\OnlineManagement\Filename.msi" /qn /norestart', '', @SW_HIDE)
	EndIf
EndIf

Open in new window

0
 

Author Closing Comment

by:ProjNet
ID: 39908937
Many thanks for the above, it worked perfectly
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Ever wondered why Windows 8 and 10 don't seem to accept your GPO-based software deployment while Windows 7 does? Read on.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

23 Experts available now in Live!

Get 1:1 Help Now