-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.bat
127 lines (101 loc) · 3.82 KB
/
install.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@echo 0ff
rem --> Obtain Admin Permission (Code provided by Eneerge sites.google.com/site/eneerge/scripts/batchgotadmin)
:: BatchGotAdmin
:-------------------------------------
rem --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
rem --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params= %*
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
echo Setting up Run at Logon...
setlocal enableextensions enabledelayedexpansion
rem --> Obtain preferred time from file
set /a count = 1
set /a list
echo %cd%
for /f %%a in ('type "set_preferred_time.txt" ^| findstr /R "[0-9]" set_preferred_time.txt') do (
set /a count += 1
set "list=!List! %%a"
)
rem --> Store time values inside array
set /a count = -1
for %%I in (%list%) do (
set /a count += 1
call set "arr[%%count%%]=%%~I"
)
rem --> Obtain shortened filepath
for %%A in ("%cd%") do set "filepath=%%~sA"
cls
rem --> Create Tasks for Light and Dark Theme
SCHTASKS /CREATE /SC DAILY /TN "Theme Changer\Light Theme" /TR "%filepath%\Source\Scripts\startLightMode.vbs" /ST %arr[0]% /DU 00:30 /K /ru %username% /it
SCHTASKS /CREATE /SC DAILY /TN "Theme Changer\Dark Theme" /TR "%filepath%\Source\Scripts\startDarkMode.vbs" /ST %arr[1]% /DU 00:30 /K /ru %username% /it
rem --> Create Auto Change task
SCHTASKS /CREATE /TN "Theme Changer\Change at log in" /TR "%filepath%\Source\Scripts\autoChange.vbs" /SC ONLOGON /ru %username% /it
rem --> Clear old address in autoChange.bat
cd Source
call "reset.bat"
cd ..\..
rem --> Copy current address to autoChange.vbs
echo Dim filepath > dir.txt
echo filepath = "%filepath%\Scripts\Batch\autoChange.bat" >> dir.txt
type autoChange.vbs >> dir.txt
del /f autoChange.vbs
type dir.txt >> autoChange.vbs
del /f dir.txt
rem --> Copy current address to startLightMode.vbs
echo Dim filepath > dir.txt
echo filepath = "%filepath%\Scripts\Batch\changeLight.bat" >> dir.txt
type startLightMode.vbs >> dir.txt
del /f startLightMode.vbs
type dir.txt >> startLightMode.vbs
del /f dir.txt
rem --> Copy current address to startDarkMode.vbs
echo Dim filepath > dir.txt
echo filepath = "%filepath%\Scripts\Batch\changeDark.bat" >> dir.txt
type startDarkMode.vbs >> dir.txt
del /f startDarkMode.vbs
type dir.txt >> startDarkMode.vbs
del /f dir.txt
cd Batch
rem --> Copy current address to autoChange.bat
echo rem "Batch is called with Admin rights and needs to be routed back to Source folder" > dir.txt
echo cd %filepath% >> dir.txt
type autoChange.bat >> dir.txt
del /f autoChange.bat
type dir.txt > autoChange.bat
del /f dir.txt
rem --> Copy current address to changeLight.bat
echo rem "Batch is called with Admin rights and needs to be routed back to Source folder" > dir.txt
echo cd %filepath% >> dir.txt
type changeLight.bat >> dir.txt
del /f changeLight.bat
type dir.txt > changeLight.bat
del /f dir.txt
rem --> Copy current address to changeDark.bat
echo rem "Batch is called with Admin rights and needs to be routed back to Source folder" > dir.txt
echo cd %filepath% >> dir.txt
type changeDark.bat >> dir.txt
del /f changeDark.bat
type dir.txt > changeDark.bat
del /f dir.txt
cls
echo Auto-dark-mode has been installed successfully!
endlocal
pause