Ohai Chefs! Here is what I am trying to accomplish: 1) Create a user 2) Make user an admin (windows requires I do this as a separate step a. Notify a Template to create a batch file i. Notify a Template to create a _vbscript_ (to run the batch file as the user that I just created)
1.
Notify an Execute resource to run the VBS Everything seems to work correctly, except the most important “run the VBS”. However there are no errors in the chef run. Of course, I can log into the machine and run VBS with expected result. So this begs the question: what am I doing wrong?! Execute “vbs” do Cwd “c:\\path\\to\\vbs” Command “cscript /nologo my.vbs” End Among the expected behaviors, there should be a log of batch file’s output, and this is not created. Here is the my.vbd.erb: set WshShell = WScript.CreateObject("Wscript.Shell") WshShell.run "runas /noprofile /user:<%= node[:cookbook][:localuser][:username] %> " + Chr(34) + "c:\chef\cache\sshWindowsUser.bat > runas_batch_log.txt 2>" + Chr(38) + "1" + Chr(34) WScript.Sleep 500 WshShell.SendKeys "<%= node[:cookbook][:localuser][:password] %>" WshShell.SendKeys "{ENTER}" set WshShell = nothing which is created as this on the target machine: set WshShell = WScript.CreateObject("Wscript.Shell") WshShell.run "runas /noprofile /user:username " + Chr(34) + "c:\chef\cache\sshWindowsUser.bat > runas_batch_log.txt 2>" + Chr(38) + "1" + Chr(34) WScript.Sleep 500 WshShell.SendKeys "TheSecretPassWord" WshShell.SendKeys "{ENTER}" set WshShell = nothing · Note that chr(34) is quotaions “surrounding the batch and logfile, and chr(38) is an ampersand, since it is a special character in ruby” ·
I have been over and over this, and since it runs correctly at the command prompt, I can’t understand why it seems to do nothing in the chef run. Thanks, Dan-Joe |
Archive powered by MHonArc 2.6.16.