Skip to content

Instantly share code, notes, and snippets.

@leonelsr
Last active April 6, 2019 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonelsr/706feca1156b1f37c2c151c10d93a508 to your computer and use it in GitHub Desktop.
Save leonelsr/706feca1156b1f37c2c151c10d93a508 to your computer and use it in GitHub Desktop.
Despertador com windows batch e task scheduler
:: Desativa a task
nircmd elevate schtasks.exe /Change /TN "Despertador" /Disable
SLEEP 5
@echo off
SETLOCAL
SET mpchc="C:\Program Files\MPC-HC\mpc-hc64.exe"
SET imperial="C:\Users\Leonel\Music\John Williams\The Greatest Hits_ 1969-1999 Disc 1\10 'The Imperial March' from The Emp.m4a"
SET dontlie="C:\Users\Leonel\Music\The Black Eyed Peas\Monkey Business\04 Don't Lie.m4a"
SET hedwig="C:\Users\Leonel\Music\John Williams\Harry Potter And The Philosopher's Stone\19 Hedwig's Theme.m4a"
SET starwars="C:\Users\Leonel\Music\John Williams\The Greatest Hits_ 1969-1999 Disc 1\01 Star Wars (Main Title) [From Star.m4a"
SET "now=%time: =0%"
SET "song=%hedwig%"
IF "%now%" geq "06:59:00,00" ( SET "song=%imperial%" )
IF "%now%" geq "07:29:00,00" ( SET song=%starwars% )
nircmd.exe mutesysvolume 0
nircmd.exe changesysvolume -65535
reg add HKEY_CURRENT_USER\Software\MPC-HC\MPC-HC\Settings /f /v Volume /t REG_DWORD /d 100
reg add HKEY_CURRENT_USER\Software\MPC-HC\MPC-HC\Settings /f /v Mute /t REG_DWORD /d 0
start "" %mpchc% %song%
FOR /L %%A IN (1,1,60) DO (
echo %%A
sleep 1
rem 30
rem nircmd.exe changesysvolume 2185
rem 60
nircmd.exe mutesysvolume 0
nircmd.exe changesysvolume 1093
)
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2018-12-02T21:46:31.2103483</Date>
<Author>FOOFIGHTERS\Leonel</Author>
<URI>\Despertador</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<StartBoundary>2018-12-02T06:15:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
<CalendarTrigger>
<StartBoundary>2018-12-04T06:30:12</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
<CalendarTrigger>
<StartBoundary>2018-12-04T07:00:02</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
<CalendarTrigger>
<StartBoundary>2018-12-17T07:30:00</StartBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-79625186-1137681888-1822082827-1001</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>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<WakeToRun>true</WakeToRun>
<ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Users\Leonel\Desktop\DESPERTADOR.cmd</Command>
</Exec>
</Actions>
</Task>
:: Instala a task
:: schtasks /create /xml "Despertador.xml" /tn "Despertador"
:: Ativa a task
:: schtasks.exe /Change /TN "Despertador" /Enable
:: NIRCMD funciona melhor
nircmd elevate schtasks.exe /Change /TN "Despertador" /Enable
SLEEP 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment