Create batch file to replace xml file restart app service and create detection rule

Hello friends, there are a lot of customized XML files we are using in the WIM and even during the Task Sequence execution. like startlayout.xml, defaultAppAssociation.xml, UDIWizard.xml.

Sometimes we are creating custom application installation through UDI Wizard using XML, some application settings need to overwrite using an XML file.

post OSD, technicians can’t copy-paste each and every XML file into the application install directory and there are chances of mistakes and can lead to a functionality break.

To overcome this issue, we can replace the application-related XML files safely during the Task sequence execution.

you have to customize your XML file and create a package along with one batch script inside it.

the batch file will act as a trigger while executing the action and use the %~dp0 functionality before the XML file name to replace the existing XML file from the package source directory. to overwrite the existing XML, we have to use the /y switch at the end of xcopy command.

If any application service is using the XML file and it's in the running state, we have to stop the service first. use sc stop and <servicename> to stop the running services.

As we are deploying the service on a new build machine, there might be an existing application deployment is set for device collection from SCCM, to stop the rerun of the production deployment on the newly build machine we have to create a detection logic so it will skip rerun behavior. 

We have added the reg add at the end of script execution.

you can copy the below script and use the above-mentioned parameters as per your requirements.

@echo on

sc stop Win10Service

xcopy "appxml.xml" C:\programdata\appxml\

TIMEOUT /t 10

sc start Win10Service

Reg Add "HKLM\Software\DetectionRules\Detectionrule" /v appxml /t REG_SZ /d 0 

No comments:

Post a Comment

Leave your valuable words here for improve better.