简体   繁体   中英

Batch file to commit changes to Embedded XP and then restart pc

I would like to create a batch file to run a cmd command to commit changes to a windows embedded pc from a USB drive and restart the PC to make the changes active.

The cmd line I use is:

ewfmgr -commit c:

But I need to open the cmd prompt and run the command then once it has run, restart the PC

This is what worked

@echo OFF
:reboot
c:\windows\system32\ewfmgr.exe C: -commit
echo Rebooting...Please Wait
c:\windows\system32\xpepm.exe -restart
pause

shutdown /? could give some hints. Then your batch file might look as follows:

ewfmgr -commit c:
shutdown /r

To ensure batch wait until ewfmgr command ends, use

start "" /W ewfmgr -commit c:
shutdown /r

With the /W or /WAIT switch, the start command will start application and wait for it to terminate. More info on start command .

To give a some kind of wait after the commit command so that it can run and finish its task, eg for a delay of 30 seconds:

  • add timeout /T 30 /nobreak>nul line before shutdown /r , and/or
  • use shutdown with /t xxx switch (this sets the time-out period before shutdown to xxx seconds), ie shutdown /r /t 30

A workaround if timeout command is not recognized: PING -n 31 127.0.0.1>nul

Create a new file with the .bat extension. Open it in your preferred text editor and enter the commands you want to be run, and save the file. The commands that JosefZ wrote would probably do the job perfectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM