Created
December 15, 2010 08:58
-
-
Save devemouse/741790 to your computer and use it in GitHub Desktop.
Script for scheduling actions after windows startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'highline/import' | |
require 'ezcrypto' | |
p "After Start" | |
tasks = [ | |
{ | |
:name => 'kill_dropbox', | |
:command => "taskkill /f /im Dropbox.exe", | |
:time => 20 | |
}, | |
{ | |
:name => 'kill_TSVNCache', | |
:command => "taskkill /f /im TSVNCache.exe", :time => 5 | |
}, | |
{ | |
:name => 'start_Todolist', | |
:command => "C:\\...\\ToDoList.exe", | |
:time => 5 | |
}, | |
{ | |
:name => 'backup_jazdy', | |
:command => "copy k:\\...\\jazdy.xls c:\\...\\dojazd /Y", | |
:time => 60 | |
}, | |
{ | |
:name => 'start_dropbox', | |
:command => "C:\\...\\Dropbox.exe", | |
:time => 7*60 | |
}, | |
] | |
pass=EzCrypto::Key.generate | |
key = pass.encrypt ask("Enter your password: ") { |q| q.echo = "*" } | |
current_tasks = %x[schtasks] | |
tasks.each do |task| | |
if current_tasks =~ /#{task[:name]}/ then | |
system("schtasks /delete /tn #{task[:name]} /f") | |
end | |
system("schtasks /create /RU synowiecd /RP " + | |
"#{pass.decrypt(key)} /sc ONCE /tn #{task[:name]} /tr \"" + | |
task[:command] + | |
"\" /st " + | |
(Time.now + (task[:time]*60)).strftime("%H:%M:%S") ) | |
end | |
pass = nil | |
keu = nil | |
current_tasks = %x[schtasks] | |
puts current_tasks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment