-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup_activator.bat
27 lines (22 loc) · 1000 Bytes
/
startup_activator.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
:: Copyright (c) 2024 Serhii I. Myshko
:: https://github.com/sergeiown/Alert_Server/blob/main/LICENSE
@echo off
set shortcutName=Alert Server
set shortcutDescription=Run Alert Server in background
set targetPath=%CD%\start_alertserver_hidden.bat
set shortcutPath=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\%shortcutName%.lnk
set iconPath=%SystemRoot%\System32\SHELL32.dll,77
set workingDirectory=%CD%
if exist "%shortcutPath%" (
del "%shortcutPath%"
if errorlevel 1 (
echo Failed to delete existing shortcut.
exit /b 1
)
) else (
powershell -Command "$WScript=New-Object -ComObject WScript.Shell; $Shortcut=$WScript.CreateShortcut('%shortcutPath%'); $Shortcut.TargetPath='%targetPath%'; $Shortcut.IconLocation='%iconPath%'; $Shortcut.WorkingDirectory='%workingDirectory%'; $Shortcut.WindowStyle=7; $Shortcut.Description='%shortcutDescription%'; $Shortcut.Save()"
if errorlevel 1 (
echo Failed to create shortcut.
exit /b 1
)
)