Solved

Batch Script Help

Posted on 2014-02-14
2
497 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help editing script 3 74
Folder Permission Powershell 4 57
Scripted configuration of TightVNC with Start on boot 7 59
Need a good Angular tutorial 5 81
Ever wondered why Windows 8 and 10 don't seem to accept your GPO-based software deployment while Windows 7 does? Read on.
Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
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…

772 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