VMware Cloud Community
sbaumgartner
Contributor
Contributor

Run script after VRMAgent activities in WinPE

I'm trying to figure out a way to run a batch script after the VRMAgent applies a WIM image but before it restarts the computer. Windows has the nasty habit of dropping partition info from the BCD when a WIM file is applied to a drive using imagex, which causes the initial boot to the newly applied image to fail. For years, we've circumvented the problem by simply firing off bcdedit commands to set the device and osdievice fields manually.

I can add a script to startnet.cmd to run after wpeinit but before VRMAgent, which I had to do to configure the drive partition and set the boot sector as leaving it to the agent results in boot errors. However, adding a script call to startnet.cmd after the VRMAgent call does no good since the agent script forces a reboot at the end, so the post script never gets called.

How can I either add additional commands to run after the WIM image is applied but before the server is rebooted, or remove the reboot component of the agent WIM provisioning activities altogether and add it to the end of my own post-application script?

Reply
0 Kudos
3 Replies
vmmeup
Expert
Expert

Check this out http://dailyhypervisor.com/vcloud-automation-center-vcac-5-1-executing-scripts-with-the-windows-gues... just don't worry about the parts that cover the guest agent installation and focus on the parts that explain how to execute a script.

Thanks,

Sid Smith

Blog: http://www.dailyhypervisor.com

Follow on Twitter: https://twitter.com/dailyhypervisor

Sid Smith ----- VCP, VTSP, CCNA, CCA(Xen Server), MCTS Hyper-V & SCVMM08 [http://www.dailyhypervisor.com] - Don't forget to award points for correct and helpful answers. 😉
sbaumgartner
Contributor
Contributor

Unfortunately the script run is a preconfigured one used for WIM provisioning that gets called from the manager, specifically as:

* VRMAgent.exe -GuestAgent -URL:<URL to VMPS2 directory on manager>

The point at which I need to execute additional commands occurs during that script, right before it reboots the machine. Unfortunately, I think that they compiled it into one of the numerous DLLs on the manager as I cannot find a trace of any of the commands that I know that it runs on the server. Pity, since it is just running standard commands otherwise and would be ridiculously easy to include what I need if saved as regular batch scripts.

I went ahead and configured the options that you listed in your article on the off-chance that vCAC would regard that WinPE call with VRMAgent as being applicable, but it did not work. Makes sense since it would inhibit the ability to use that functionality during first run of the OS if using WIM provisioning.

However, that is exactly the info that I needed for other things that I've been planning on implementing. Smiley Happy Thank you very much for that link; good site, by the way.

Reply
0 Kudos
vmmeup
Expert
Expert

I'll see if I can muster up the time to write a tutorial on how to do what you are asking.  No promises on it being this week, but I'll try.

Thanks,

Sid Smith

Blog: http://www.dailyhypervisor.com

Follow on Twitter: https://twitter.com/dailyhypervisor

Sid Smith ----- VCP, VTSP, CCNA, CCA(Xen Server), MCTS Hyper-V & SCVMM08 [http://www.dailyhypervisor.com] - Don't forget to award points for correct and helpful answers. 😉
Reply
0 Kudos