Solved

Batch Script Help

Posted on 2014-02-14
2
505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using VBS script to log into internal website 6 41
Exchange Certification Training 5 61
Server overheating 7 56
Writing reports to a script 7 26
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
We asked our MSP customer base what their favorite tools were and how they help them serve clients. We focused our questions on favorite tools in the following categories: >PSA tools >RMM tools >Alert management tools >Communication tools and Mo…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

734 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