Ask Your Question
0

delete service name using exec

asked 2016-06-21 18:24:37 -0600

puppetamateur gravatar image

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-06-21 23:45:11 -0600

DarylW gravatar image

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.

edit flag offensive delete link more
0

answered 2016-06-23 11:21:33 -0600

puppetamateur gravatar image

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 }

edit flag offensive delete link more

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: 2016-06-21 18:24:37 -0600

Seen: 74 times

Last updated: Jun 23 '16