# delete service name using exec

HI,

I am trying to delete a windows service using the following:

exec { 'service': command => 'sc delete servicename'; }

it gives me error 'sc delete servicename' is not qualified and no path was specified.

since the command doesn't need any path, I gave a random path to fulfil the criteria. Then it gives me is not qualified and no path was specified. error

edit retag close merge delete

Sort by » oldest newest most voted

I haven't done much on the windows side of the house, but exec's always need either a correct path supplied, or a fully qualified path to the executable in the command.

in powershell, I see the following..

PS C:\tmp> (get-command sc.exe).Path
C:\Windows\system32\sc.exe


Try either using that as your fully qualified path, or adding C:\Windows\system32 as your exec's path parameter.

more

I figured. It is simple 'sc delete servicename'.

The thing to remember while calling it in puppet is, exec resource package asks for a path and sc delete doesn't have a path. So the script can look like:

exec{'delete service": command => 'sc delete servicename', path => \$::path }

more