Scripting Question

I Need Batch file to Delete file+ add registry + more for SCCM 2012 r2 silent deployment

06/30/2016 3107 views
@echo off
pushd %~dp0
cscript \\Server\Applications\KillOutlook\KillOutlook.vbs
echo ### Delete outlook1
attrib -r c:\Program Files (x86)\Microsoft Office\Office14\Outlook.exe
echo ### Delete outlook2
del "c:\Program Files (x86)\Microsoft Office\Office14\Outlook.exe" /f
echo ### Delete Outlook Profile
reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" /f
echo ### Create a folder
Regedit.exe /s \\Server\Applications\KillOutlook\OutlookProfile.reg
echo ### Create OutlookProfile
md c:\Temp\OutlookProfile <  for detection

Is this correct?  sometime some of them does not run .. any idea
1 Comment   [ + ] Show comment


  • I believe the commandline that is not working for you is the registry that you are trying to delete from the current user profile. Since it is running in SYSTEM account, you would not see the registry deleted. Creating a powershell script to delete the registry in all the hives should make it work.

Community Chosen Answer


Additionally, the System account won't have network access so the calls to '\\Server\Applications...' will fail.

Changing the script to run as the logged-in user means that the file deletions will fail. Quite why anyone would regard deletion of the EXE as a practical solution escapes me so what is it you're trying to achieve?

Answered 07/01/2016 by: anonymous_9363
Red Belt

All Answers

looking over this, you're wanting to delete the outlook.exe, is there a particular reason just to delete the outlook.exe?

also you can substitute the vbs for taskkill /IM Outlook.exe if you want an immediate termination

also the key youre deleting is in HKCU as the batch file will be running under the system account it will remove it for the system user. you can add it to an application task sequence and tell it to run a commandline under as the current logged in user

you shouldn't need to run the attib against outlook.exe prior to removal
Answered 07/01/2016 by: sparky86
Fourth Degree Brown Belt

  • how you can add it to an application task sequence and tell it to run a commandline under as the current logged in user ?
    • you can create a custom task sequence then add general and run command line then insert the following before the command you want to execute

      Serviceui.exe -process:TSProgressUI.exe <command to run>

      for the other tasks such as network share related tasks you can check the box to say run this step as the following account and specify the account to run it as
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ