If all your batch script does is tweak some registry settings, I would suggest ditching batch files entirely and use the puppetlabs-registry module instead.

That said, it is likely that your script is not being executed at all because you need to escape backslashes in paths, e.g.

          command => "cmd.exe /c c:\\temp\\sageset.bat",

Because backslashes are escape characters, the path is being flattened to "c:tempsageset.bat" which clearly doesn't exist; escaping the backslashes will resolve that.

But using the registry module is much better, and you should do that to avoid much sadness.

- Peter


On 7/29/2015 3:48 PM, Dimitri Yioulos wrote:
Hello, all.

I'm trying to execute the following batch file (sageset.bat) on Win2k8 servers:

@ECHO OFF
REM Enable components to cleanup
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders" /v StateFlags0100 /d 2 /t REG_DWORD /f REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\BranchCache" /v StateFlags0100 /d 2 /t REG_DWORD /f REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files" /v StateFlags0100 /d 2 /t REG_DWORD /f REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\GameNewsFiles" /v StateFlags0100 /d 2 /t REG_DWORD /f
~

It makes changes to registry settings so that the disk cleanup utility will do a more thorough job of cleanup. It's the equivalent of running "cleanmgr /d c: /sageset:100", which opens a dialog box that presents a list of files to clean that one can check.

The following is in my manifest:

exec { 'sageset.bat':
         path => $::path,
         command => "cmd.exe /c c:\temp\sageset.bat",
         provider => windows,
         logoutput => true,
        }

The results of the manifest run are that everything executed successfully. However, if I run "cleanmgr /d c: /sageset:100" after that, none of the boxes is checked. Running the batch file in a Windows CLI does work, and if I run "cleanmgr /d c: /sageset:100" after that, all of the boxes are checked.

Why am I not getting this to work?

Dimitri
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com <mailto:puppet-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/30c76fb5-d8b6-4107-9300-6773fc15e36a%40googlegroups.com <https://groups.google.com/d/msgid/puppet-users/30c76fb5-d8b6-4107-9300-6773fc15e36a%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/55B935C9.1020301%40alter3d.ca.
For more options, visit https://groups.google.com/d/optout.

Reply via email to