?
Solved

Batch Script Help

Posted on 2014-02-14
2
Medium Priority
?
511 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 2000 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

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

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

New style of hardware planning for Microsoft Exchange server.
Introducing Priority Question, our latest feature.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Suggested Courses

764 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