Solved

Batch Script Help

Posted on 2014-02-14
2
490 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
Comment Utility
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
Comment Utility
Many thanks for the above, it worked perfectly
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Ever wondered why Windows 8 and 10 don't seem to accept your GPO-based software deployment while Windows 7 does? Read on.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

12 Experts available now in Live!

Get 1:1 Help Now