@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   [ - ] Hide 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.
Please log in to comment

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: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity


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
Please log in to comment
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja