This should be easy. I have been banging my head all afternoon on this.
VC 2.5 ESX 3.5
I have a Windows 2003 Server Template that we are deploying. I want to issue a "Run Once" command. Nothing seems to work.
I tried the following:
Regedit /s /d "HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent\AgentGUID"
Regedit /s /d "HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent\MACADDRESS"
I tried putting them in a bat file and using:
C:\Utilities\RunOnce.bat > C:\Utilities\RunOnce.out.txt 2>&1
I would prefer the .bat file method would work. I have tried many variations and other very simple commands. What very simple concept am I missing here??? Is there a log somewhere that I can use to find out if there are errors?
Confusion here. The key I am deleting is the command that I am trying to put in the customization Run Once... The problem is so fundamental that I can't describe it and this forum may not realize how easy the answer might be...
Basically, I create a customization specification. This is VMWare 101.
In the customization specification, on the wizard dialog named "Run Once" (after "Time Zone" and before "Network") I add commands.
I deploy the machine from the template with the customization specification.
The "Run Once" commands don't execute! How do I fix that? Where do I start troubleshooting this very basic VMWare 101 problem? Is there a trick to that part of the customization wizard?
So your "run once" is calling the .bat on the local c: drive? That
batch file then updates some regisrty keys? your run once should look
something like C:\Utilities\RunOnce.bat. Inside that .bat all the parameters should be setup.
You also have it set to automitically log on as administratorwith aleast 1 login?
The easist way to do this is watch the console and see what is going on.
You got it.
I have a bat file "RunOnce.bat"
On the prior wizard dialog box "Administrator Password" I checked "Automatically Log On" I set the Number of Times to Log on to "1"
I then added the runonce command.
One more note. I watch the console, and nothing happens. The commands never execute whether I put them in a batch file or try to execute them from Run Once.
Any other idea where to go to troubleshoot this?
Does anyone have a sample that should work?
OK, I see now, but umm.. I think the issue here is that sysprep is part of the deployment. There are steps that supercede registry function, because the machine isn't normal boot at that point, sysprep is running some outstanding commands, and that's why runonce is ignored.
so probably you need to put a batch file to run your commands by a global policy, then reboot the machine, the it should execute just fine. but during a deployment you don't have control of the machine, sysprep does. Until that service is done, nothing else will update. Also you can add some steps in the Sysprep customization to run additional commands, try adding them there.
But in either case this isn't an ESX / Deployment / VC bug this is a Windows problem, and probably you will have better luck getting help on a Windows forum (or Microsoft KB).
I did. I am starting to research sysprep.
I still admit that I don't fully understand why "Run Once" exists as an option in the customization wizard for any windows box.
One more note.
At times, my batch file did nothing to the registry. All the batch file did was: echo "Please work" > c:\Utilities\test.txt
Your last email indicated that as long as sysprep is used, the runonce will not work from the customization specification.
I just want to make sure that is the case...
I have to agree with you. I am trying to run a runonce command using the guest customization and it fires off but does notthing. I am not sure that the earlier answer is in line with your question. If anyone has had any success with guest customization and runone inside the vmware guest customization please respond.
I have been having similar problems.
We use the run once setup the time/date string as expected for the application. It seems if we set it in the template during sysprep it is reset.
What I think is happening is that the run once command is running before sysprep is done. Seems a step at the end of the sysprep logs in as the local administrator and this causes the bat file to start and then VM reboots before it is done. Could the VMware cusomtization be suing the run once parameter to start ?
This is what i noticed too. Occasionally depending on what you execute in your runonce script (reg query is a good one) you can see errors caused by early termination of apps as the final part of sysprep reboots after it has logged in (and prematurely kicked off the runonce script)
Because all my stuff needed to run after the VM had joined the domain, I ended up using GP startup scripts, only problem is they will run every reboot.. gotta watch out for that!
I spent the last day or two trying to automate some post installation steps for our VMware cloning process. We wanted to push things like AV installations, move the computer to the correct OU, verify it joined the domain or re-join it to the domain (issues with static IPs), etc.
From what I have gathered, the VMware Customization's Run Once commands get stuffed into the sysprep section. As sysprep states, any commands are executed on the first user login with that user's credentials and within their profile.
The important piece to note, and I am not an expert on this, is that the commands in the aka the VMware Run Once are not processed by a command interpreter. Meaning cmd.exe is not what is executing these processes. My best guess is that explorer.exe or some shell app is what is actually running the commands passed into via the Run Once section of the VMware customizations.
Therefore, if you want to execute DOS commands such as echo, pause, reg, psexec, etc, you need to use cmd /c
For example, these work:
cmd /c echo "Hello World" > C:\test.txt
These do not work:
echo "Hello World" > C:\test.txt
It seems that "net use" works without a cmd /c which is intriguing, but I have not thoroughly tested this yet. I assume *.bat and *.cmd would work with or without cmd /c since they would initiate a cmd interpreter.
Additionally Neither of these work.
cmd /c reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce" /t REG_SZ /v Start_Notepad /d notepad.exe
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce" /t REG_SZ /v Start_Notepad /d notepad.exe
cmd /c reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /t REG_SZ /v Start_Notepad /d notepad.exe
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /t REG_SZ /v Start_Notepad /d notepad.exe
At this point I am not quite sure if you can manipulate the registry in the . It seems these should work, but they do not appear to be working. All the above commands work after the computer is booted. Something after the either overwrites these changes or discards the changes. That is my theory.
I hope that sheds some light on this topic, and I spent a good 4 hours on Google and i could not find any blog, forum, kb article that stated to use cmd /c when submitting dos commands via Run Once.
I was trying do to something similar (delete a reg key) with "Run Once". It didn't work for me either until I removed the quotes in the reg command:
ie, reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce" /t REG_SZ /v Start_Notepad /d notepad.exe
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce /t REG_SZ /v Start_Notepad /d notepad.exe
Hope this helps,