JoshEmory
JoshEmory

Reputation: 644

Is there a ruby gem to start/stop Windows Scheduled Tasks?

I'm looking for a ruby gem that can start/stop an already running windows scheduled tasks. Or if a gem does not exist, another work around for doing such a thing.

Upvotes: 2

Views: 184

Answers (1)

JoshEmory
JoshEmory

Reputation: 644

I believe I found the best answer, but someone else can please correct me if I'm wrong. I think my best option is to just send a command using the Windows CLI.

Looking at the windows the windows documentation it appears the command to stop a task in Windows CLI is schtasks /End [/S <system> [/U <username> [/P [<password>]]]] /TN taskname.

The command to start a task is schtasks /Run [/S <system> [/U <username> [/P [<password>]]]] /TN <taskname>.

So, with those two things in mind, in the ruby script I can use %x(windows cli command), system 'windows cli command', with varying levels of returned data. I believe there's some more from what I was reading, but I think that will work. Again, if anyone has comments or a better plan on action for what I'm trying to do, definitely all ears.

Upvotes: 1

Related Questions