-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_menu_shortcut.bat
50 lines (43 loc) · 2.47 KB
/
start_menu_shortcut.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
:: Copyright (c) 2024 Serhii I. Myshko
:: https://github.com/sergeiown/Alert_Server/blob/main/LICENSE
@echo off
set folderName=Alert Server
set folderPath=%APPDATA%\Microsoft\Windows\Start Menu\Programs\%folderName%
set shortcutName=Alert Server tray
set shortcutTargetDescription=Run Alert Server minimized to the tray
set targetPath=%CD%\start_alertserver_hidden.bat
set shortcutAltName=Alert Server tray and console
set shortcutAltTargetDescription=Run Alert Server minimized to the tray with access to the console
set targetAltPath=%CD%\start_alertserver_visible.bat
set shortcutUninstallName=Uninstall Alert Server
set shortcutUninstallDescription=Uninstall Alert Server from the system
set uninstallPath=%CD%\start_uninstall.bat
set iconPath=%SystemRoot%\System32\SHELL32.dll,77
set workingDirectory=%CD%
if exist "%folderPath%" (
rmdir /s /q "%folderPath%"
if errorlevel 1 (
echo Failed to remove existing folder "%folderPath%"
exit /b 1
)
)
mkdir "%folderPath%"
if errorlevel 1 (
echo Failed to create folder "%folderPath%"
exit /b 1
)
powershell -Command "$WScript=New-Object -ComObject WScript.Shell; $Shortcut=$WScript.CreateShortcut('%folderPath%\%shortcutName%.lnk'); $Shortcut.TargetPath='%targetPath%'; $Shortcut.IconLocation='%iconPath%'; $Shortcut.WorkingDirectory='%workingDirectory%'; $Shortcut.Description='%shortcutTargetDescription%'; $Shortcut.WindowStyle=7; $Shortcut.Save()"
if errorlevel 1 (
echo Failed to create shortcut "%folderPath%\%shortcutName%.lnk"
exit /b 1
)
powershell -Command "$WScript=New-Object -ComObject WScript.Shell; $Shortcut=$WScript.CreateShortcut('%folderPath%\%shortcutAltName%.lnk'); $Shortcut.TargetPath='%targetAltPath%'; $Shortcut.IconLocation='%iconPath%'; $Shortcut.WorkingDirectory='%workingDirectory%'; $Shortcut.Description='%shortcutAltTargetDescription%'; $Shortcut.WindowStyle=1; $Shortcut.Save()"
if errorlevel 1 (
echo Failed to create shortcut "%folderPath%\%shortcutAltName%.lnk"
exit /b 1
)
powershell -Command "$WScript=New-Object -ComObject WScript.Shell; $Shortcut=$WScript.CreateShortcut('%folderPath%\%shortcutUninstallName%.lnk'); $Shortcut.TargetPath='%uninstallPath%'; $Shortcut.IconLocation='%iconPath%'; $Shortcut.WorkingDirectory='%workingDirectory%'; $Shortcut.Arguments='-Verb RunAs'; $Shortcut.Description='%shortcutUninstallDescription%'; $Shortcut.WindowStyle=7; $Shortcut.Save()"
if errorlevel 1 (
echo Failed to create shortcut "%folderPath%\%shortcutUninstallName%.lnk"
exit /b 1
)