[chef] Re: Trouble running VBS with Execute resource


Chronological Thread 
  • From: Stephen Rosen < >
  • To: " " < >
  • Subject: [chef] Re: Trouble running VBS with Execute resource
  • Date: Sat, 26 Sep 2015 12:26:43 +0000

Hi Dan-Joe,

I don't have experience with Chef on Windows, but...

Have you tried running with `-l debug`?
I've found that often leads me to the solution when a resource is not running even though I expect it to.

I'd also be curious where in the chef-client output the execute resource appears.
If it shows up with "action: nothing", that's not so exciting, but if it has "action: run" and isn't running the script, it may mean that there's a critical difference between your environment when manually testing and the environment of the execute.

Best,
Stephen


On Thu, Sep 24, 2015, 20:32 Dan-Joe Lopez < "> > wrote:

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.

§