/build/static/layout/Breadcrumb_cap_w.png

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

@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. - Sidhugadu 8 years ago

Answers (2)

Posted by: anonymous_9363 8 years ago
Red Belt
2

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?

Posted by: sparky86 8 years ago
Fourth Degree Brown Belt
1
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

Comments:
  • how you can add it to an application task sequence and tell it to run a commandline under as the current logged in user ? - omarohio 8 years ago
    • 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 - sparky86 8 years ago
 
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