Ask Your Question
0

Exec Resource with Reg Query Fails

asked 2013-07-31 21:22:35 -0600

louis gravatar image

Hi,

I am having some problems trying to get the unless attribute to work with the following reg.exe query to check if framework 4.5 is installed and not to execute the installer again.

 Exec  { path => [ "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\","C:\\Windows\\sysnative\\","C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\","C:\\Windows\\System32\\wbem\\" ] } 

  exec { 'netframework45':
    command   => 'powershell.exe write-host "hello"',
    logoutput => true,
    timeout   => 900,
    unless    => 'cmd /c "C:\Windows\System32\reg.exe query \"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"| findstr.exe 4.5.50709"',
  }
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-08-01 15:12:02 -0600

louis gravatar image

Your answer didn't work but i figure out with this one.

unless    => 'cmd /c reg.exe query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" | findstr.exe 4.5.50709',

This is working perfect for me now :)

edit flag offensive delete link more
0

answered 2013-08-01 11:42:56 -0600

GregLarkin gravatar image

updated 2013-08-01 13:08:45 -0600

You may have to escape the backslashes in the registry key name (and possibly the space character) to get it to work.

Example:

 Exec  { path => [ "C:\\Windows\\sysnative\\WindowsPowerShell\\v1.0\\","C:\\Windows\\sysnative\\","C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\","C:\\Windows\\System32\\wbem\\" ] } 

  exec { 'netframework45':
    command   => 'powershell.exe write-host "hello"',
    logoutput => true,
    timeout   => 900,
    unless    => 'cmd /c "C:\\Windows\\System32\\reg.exe query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\NET\ Framework\ Setup\\NDP\\v4\\Full\"| findstr.exe 4.5.50709"',
  }
edit flag offensive delete link more

Comments

I dont think i can get rid of the space character since is required. Wondering if there is another way of doing this.

louis gravatar imagelouis ( 2013-08-01 12:36:26 -0600 )edit

Sorry, I meant that you may need to escape the space character as well. I'll edit the answer with the modified resource.

GregLarkin gravatar imageGregLarkin ( 2013-08-01 13:07:36 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-07-31 21:22:35 -0600

Seen: 901 times

Last updated: Aug 01 '13