-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathsch_On.bat
More file actions
68 lines (58 loc) · 2.54 KB
/
sch_On.bat
File metadata and controls
68 lines (58 loc) · 2.54 KB
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
@echo off
:: Check for elevation
fsutil dirty query %systemdrive% >nul 2>&1
if '%errorlevel%' NEQ '0' (
:: Not elevated, so relaunch using vbscript
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c ""%~f0"" %*", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /b
)
setlocal
:: =============================================================================
:: = Setup Scheduled task for elevated AltSnap auto-start without UAC prompt =
:: = Make sure you are running this from an elevated shell =
:: = Default AltSnap executable location is %%APPDATA%%\AltSnap\AltSnap.exe =
:: = Adjust the executable location in the AltSnap.xml file if AltSnap is =
:: = installed in a different location =
:: = If you do not want to continue, close the window or hit Ctrl+C =
:: =============================================================================
echo =============================================================================
echo = Setup Scheduled task for elevated AltSnap auto-start without UAC prompt =
echo = Make sure you are running this from an elevated shell =
echo = Default AltSnap executable location is %%APPDATA%%\AltSnap\AltSnap.exe =
echo = Adjust the executable location in the AltSnap.xml file if AltSnap is =
echo = installed in a different location =
echo = If you do not want to continue, close the window or hit Ctrl+C =
echo =============================================================================
set "AltSnapXML=%APPDATA%\AltSnap\AltSnap.xml"
set "AltSnapExe=%APPDATA%\AltSnap\AltSnap.exe"
:: Check if AltSnap.exe exists
if not exist "%AltSnapExe%" (
echo.
echo AltSnap executable not found in the default location: %AltSnapExe%
echo Please ensure AltSnap is installed or specify the correct path in the AltSnap.xml file.
echo.
pause
exit /b 1
)
:: Check if AltSnap.xml exists
if not exist "%AltSnapXML%" (
echo.
echo AltSnap.xml file not found: %AltSnapXML%
echo Please ensure the AltSnap.xml file exists in the specified location.
echo.
pause
exit /b 1
)
echo.
echo Going to run command:
echo schtasks.exe /CREATE /XML "%AltSnapXML%" /TN "AltSnap" %*
echo.
pause
schtasks.exe /CREATE /XML "%AltSnapXML%" /TN "AltSnap" %*
echo.
pause
endlocal
exit /b 0