Skip to content

Instantly share code, notes, and snippets.

@davidruhmann
Last active May 8, 2016 16:43
Show Gist options
  • Save davidruhmann/a54de166e3bbf5d4a383 to your computer and use it in GitHub Desktop.
Save davidruhmann/a54de166e3bbf5d4a383 to your computer and use it in GitHub Desktop.
Option Explicit
Dim args
args = """" & WScript.Arguments(0) & """"
Dim i
Dim temp
For i = 1 to WScript.Arguments.Count - 1
temp = WScript.Arguments(i)
temp = Replace(temp, " ", "")
temp = Replace(temp, " ", "")
temp = Replace(temp, "^", "")
temp = Replace(temp, "&", "")
temp = Replace(temp, "|", "")
temp = Replace(temp, "<", "")
temp = Replace(temp, ">", "")
temp = Replace(temp, "%", "")
If StrComp(WScript.Arguments(i), temp) = 0 Then
args = args & " " & WScript.Arguments(i)
Else
args = args & " """ & WScript.Arguments(i) & """"
End If
Next
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Dim obj
obj = WshShell.Run(args, 0, False)
Set WshShell = Nothing
WScript.Quit
$pick = ls -recurse -include *.bmp,*.jpg,*.png | sort lastwritetime | select -index 0; (ls $pick).LastWriteTime = Get-Date;
$deck = ls -recurse -include *.bmp,*.jpg,*.png | sort lastwritetime | select -first 3; $index = get-random -minimum 0 -maximum $deck.count; $pick = ls $deck | select -index $index; (ls $pick).LastWriteTime = Get-Date;
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2015-02-11T10:06:22.6992337</Date>
<Author>DavidRuhmann</Author>
</RegistrationInfo>
<Triggers>
<TimeTrigger>
<Repetition>
<Interval>PT20M</Interval>
<StopAtDurationEnd>false</StopAtDurationEnd>
</Repetition>
<StartBoundary>2015-02-11T10:05:17.837334</StartBoundary>
<ExecutionTimeLimit>PT2M</ExecutionTimeLimit>
<Enabled>true</Enabled>
</TimeTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>User</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>true</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT2M</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>HiddenTask.vbs</Command>
<Arguments>powershell -command "$total = ls -recurse -include *.bmp,*.jpg,*.png | measure | select count; $index = get-random -minimum 1 -maximum $total.count; $pick = ls -recurse -include *.bmp,*.jpg,*.png | select -index $index; set-itemproperty -path 'HKCU:Control Panel\Desktop' -name wallpaper -value $pick.fullname; $path = $env:appdata + '\Microsoft\Windows\Themes'; $tw = $path + '\TranscodedWallpaper'; $ini = $path + '\slideshow.ini'; del $tw; clc $ini; $signature = '[DllImport(' + [char]0x22 + 'user32.dll' + [char]0x22 +', SetLastError = true, CharSet = CharSet.Auto)] public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);'; $type = Add-Type -MemberDefinition $signature -Name Win32Utils -Namespace SystemParametersInfo -PassThru; $type::SystemParametersInfo(20, 0, $pick.fullname, 0x01 -bor 0x02); rundll32.exe user32.dll, UpdatePerUserSystemParameters;"</Arguments>
<WorkingDirectory>%UserProfile%\Pictures\Backgrounds\Show</WorkingDirectory>
</Exec>
</Actions>
</Task>
@CalebMerkel
Copy link

hiddentask.vbs gives a runtime error on windows 10, line 3 char 1, subscript out of range code 800A0009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment