Last active
January 11, 2019 05:55
-
-
Save mkp246/52a0be863cfb6c764f7e8c1e904e6440 to your computer and use it in GitHub Desktop.
If you are using office Laptop and don't want to run office specific programs at startup when you are outside of office time or weekend
This file contains 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
@echo off | |
setlocal enableextensions enabledelayedexpansion | |
SETLOCAL | |
set ctime=%time: =0% | |
set inoffice=y | |
if "%ctime%" lss "09:00:00,00" ( set "inoffice=" ) | |
if "%ctime%" geq "18:00:00,00" ( set "inoffice=" ) | |
for /F "skip=2 tokens=2-4 delims=," %%A in ('WMIC Path Win32_LocalTime Get DayOfWeek /Format:csv') do set daynumber=%%A | |
if /I %daynumber% EQU 6 set notofficeday=y | |
if /I %daynumber% EQU 0 set notofficeday=y | |
if defined inoffice if not defined notofficeday ( | |
choice /C YN /T 10 /D Y /M "Press N to abort in 10 seconds" | |
if !ERRORLEVEL! EQU 2 goto endoffile | |
echo Starting Apps.... | |
cd %~dp0* | |
for /f %%i in ('dir /b *.lnk') do %%i | |
) else ( | |
echo You Are Not In Office Enjoy | |
) | |
ENDLOCAL | |
:endoffile | |
REM pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
put this file in startup folder (RUN> shell:startup) with all .lnk to start.
OR
put it in folder with all .lnk to start and put .lnk for this batch script in startup folder.
Configuration
at line 6 and 7 configure office start and end time.
at line 20 more programs can be added. BY default all shortcuts( .lnk files ) are started.