Elgoots
Elgoots

Reputation: 158

create a windows 8 task schedule for a vbscript using a script

I have some payback at work i need to take care of. I have a fellow worker that has been the "funny man" for a few weeks now.

I have a background i know that will drive him nuts. I have limited time while he walks off to change his background to something i know he will get mad at.

I have made a vbscript that changes his background as soon as its executed on windows 8.

but want i wanted to do, is have it set a task schedule in windows 8 to auto run it every 30 minutes so if he changes it to something else it will auto change back again and drive him bonkers. I know i can manually set this but time is limited. So to be able to plant the files and execute a bash script that creates a task schedule to run that vbscript would be awesome.

The VBScript i have tested and working to change the background is below:

dim shell
Set shell = WScript.CreateObject("WScript.Shell")
wallpaper = "C:\WINDOWS\system_logs\maxresdefault.jpg"
shell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", wallpaper
shell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True

Upvotes: 1

Views: 382

Answers (1)

Soheil
Soheil

Reputation: 837

Please remove bash tag from your question !
You should use schtasks
Syntax :

schtasks /create /tn TaskName /tr TaskRun /sc minute [/mo {1 - 1439}] [/st StartTime] [/sd StartDate] [/ed EndDate] [/s computer [/u [domain]user /p password]] [/ru {[Domain]User | "System"} [/rp Password]]

schtasks /create /sc minute /mo 30 /tn "background changer" /tr c:\changer.vbs

Upvotes: 2

Related Questions