Vagrant shell provisionning on a Windows Guest (background task issue)

655 views
Skip to first unread message

Clément Sezettre

unread,
Jul 28, 2014, 10:43:41 AM7/28/14
to vagra...@googlegroups.com
Hi,

I have a problem while provisionning  my virtual machine with shell script, the script should launch normally a .exe file but instead starts the .exe in background task.
I'd like to know if someone met the same issue before.






Clément Sezettre

unread,
Jul 30, 2014, 6:29:49 AM7/30/14
to vagra...@googlegroups.com
My windows Guest is a Windows Server 2012.
 I did exactly the same as the tutorial https://github.com/WinRb/vagrant-windows
My batch file is a start command to launch a .exe on the guest machine.
Message has been deleted

Clément Sezettre

unread,
Jul 31, 2014, 9:00:56 AM7/31/14
to vagra...@googlegroups.com
Is it the "vagrant-elevated-shell.ps1" in C:\Temp that create the scheduled task ?
Because when i change something in the code of the ps1 file. Nothing happened in the Task scheduler.
In the task  "WinRM_Elevated_Shell", "Run whether user is logged on or not" is checked and because the other choice is not checked "Run only when user is logged on" the script start in background. I'd like to find a way to modify the code that create the task in order to check the other choice.

If anyone has a idea, i'm completly lost.

Shawn Neal

unread,
Aug 1, 2014, 10:59:35 AM8/1/14
to vagra...@googlegroups.com
I don't know why you're trying to do this, but the Vagrant source which generates the scheduled task is here: https://github.com/mitchellh/vagrant/blob/master/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb

You can also _not_ use a scheduled task with the shell provision by setting elevated => false.

Shawn Neal

unread,
Aug 1, 2014, 11:00:19 AM8/1/14
to vagra...@googlegroups.com
Should have said privileged => false

Clément Sezettre

unread,
Aug 4, 2014, 2:46:05 AM8/4/14
to vagra...@googlegroups.com
I created a script with "AutoIt" to install a software in silent mode. But the .exe can only be launched in interactive process.
I want with Vagrant to launch this .exe in Interactive. with this setting (privileged=false) nothing happens now.

Clément Sezettre

unread,
Aug 5, 2014, 6:24:27 AM8/5/14
to vagra...@googlegroups.com
I'll try to explain it a bit more detailled.

I have a Windows 7 Host and windows 2012/windows 2008 guests
on guests there is a .exe file in c:\vagrant\thinkserver, i want this file to be launch in interactive mode thanks to the shell provisioning.
The .exe file is an AutoIt script, this script will install a complete software.

I would like to start this file as if i doubled click on it. I don't know if this is possible. 
Thanks for helping me.

backgroundProc.png
script.txt
Vagrantfile.txt

Alvaro Miranda Aguilera

unread,
Aug 5, 2014, 6:42:41 AM8/5/14
to vagra...@googlegroups.com
in windows there is a command called open

can you do cmd

open /?

and see those options?

usually open /min <lelele.exe>  will open a new task minimized but foreground..




--
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Clément Sezettre

unread,
Aug 6, 2014, 2:36:15 AM8/6/14
to vagra...@googlegroups.com
I've been looking http://ss64.com/nt/ for a while now and i didn't find any command to play a windows in foreground.

Alvaro Miranda Aguilera

unread,
Aug 6, 2014, 8:47:54 PM8/6/14
to vagra...@googlegroups.com
My bad! sorry

start /?

http://ss64.com/nt/start.html

start /min cmd

will open a new cmd command minimized but in foregroud



On Wed, Aug 6, 2014 at 6:36 PM, Clément Sezettre <clement....@gmail.com> wrote:
I've been looking http://ss64.com/nt/ for a while now and i didn't find any command to play a windows in foreground.

Clément Sezettre

unread,
Aug 8, 2014, 5:50:30 AM8/8/14
to vagra...@googlegroups.com
Nop still not working, I think it's because WinRM works in background on the guest machine.  

Shawn McCarthy

unread,
Aug 8, 2014, 9:38:19 AM8/8/14
to vagra...@googlegroups.com
I had a similar problem (I was starting a batch script using the Vagrant file, but the batch script doesn't finish. It is a service, so it stays open, waiting commands. The Command Prompt on my windows VM wasn't appearing either. It was in the Processes List thought I think.)

The way I fixed it was by using my Vagrant file to add the batch script to the Task Scheduler, than running that new scheduled task using the Vagrant file.


Here is an example :

$start_selenium_grid = <<SCRIPT
schtasks /create /XML "C:/selenium-grid-extras/Selenium-Grid-Extras.xml" /TN "Selenium-Grid-Extras"
schtasks /run /tn "Selenium-Grid-Extras"
SCRIPT

  config.vm.provision :shell, :inline => $start_selenium_grid



I was forced to use /XML instead of just passing in the information, because if I just passed in the information, it wouldn't run from the command line if not plugged in. Create the task manually one time in Task Scheduler, than export it to XML, and use that XML.

Inside the XML file you will see the command to run my batch script.


I hope this helps!

Shawn

Clément Sezettre

unread,
Aug 21, 2014, 6:30:23 AM8/21/14
to vagra...@googlegroups.com
Worked perfectly !! Thank you so much !
Reply all
Reply to author
Forward
0 new messages