Created
May 22, 2014 16:28
-
-
Save jeremiahsnapp/fc829ac990b1581826ec to your computer and use it in GitHub Desktop.
async process on windows that doesn't block chef run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async process on windows that doesn't block chef run | |
batch "run" do | |
code 'powershell -c "start-process notepad.exe"' | |
end | |
https://opscode.hipchat.com/history/room/12542/2013/10/15?q=notepad.exe#17:43:33 | |
http://technet.microsoft.com/en-us/library/hh849848.aspx | |
The following is an example of using start-process to start a command with arguments. | |
Try running the command by itself in the command prompt to familiarize yourself with its output. | |
net statistics server | |
Now run it using powershell and start-process in the command prompt and verify the correct output shows in c:\output.txt. Please pay careful attention to the use of single or double quotes. My experience says start-process won't work with double quotes for some reason. | |
powershell -c start-process net -ArgumentList 'statistics workstation' -RedirectStandardOutput c:\output.txt | |
Now put the following in a Chef execute resource and run it. Again, be aware of the single quotes, double quotes and escaped single quotes. | |
execute "run" do | |
command 'powershell -c "start-process net -ArgumentList \'statistics workstation\' -RedirectStandardOutput c:\chef-output.txt"' | |
end | |
You should find the correct output in c:\chef-output.txt. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment