-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_menu_shortcut_enabler.bat
37 lines (32 loc) · 1.72 KB
/
start_menu_shortcut_enabler.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
:: Copyright (c) 2024 Serhii I. Myshko
:: https://github.com/sergeiown/Winget_Upgrade/blob/main/LICENSE
@echo off
set shortcutName=winget_upgrade
set shortcutTargetDescription=Run checking for updates
set targetPath=%CD%\winget_upgrade.exe
set folderPath=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
set shortcutPath=%folderPath%\%shortcutName%.lnk
set iconPath=%SystemRoot%\System32\SHELL32.dll,13
set workingDirectory=%CD%
:: WindowStyle=
:: 1 - Normal window: opens the window in a normal size and position
:: 2 - Hidden window: window is hidden, process runs in the background
:: 3 - Maximized window: opens the window maximized (full screen)
:: 4 - Normal window (same as 1): opens the window in a normal mode
:: 5 - Minimized window: opens the window minimized (in taskbar)
:: 6 - Minimized window with active focus: window is minimized, but still active
:: 7 - Minimized window (same as 5): opens the window minimized
set windowStyle=1
if not exist "%targetPath%" (
echo Error: The target file "%targetPath%" does not exist. Operation aborted. & echo.
pause
exit /b
)
if exist "%shortcutPath%" (
echo The shortcut "%shortcutPath%" exists. & echo. & echo Deleting the shortcut. & echo.
del "%shortcutPath%"
) else (
echo The shortcut "%shortcutPath%" does not exist. & echo. & echo Creating a shortcut. & echo.
powershell -Command "$WScript=New-Object -ComObject WScript.Shell; $Shortcut=$WScript.CreateShortcut('%shortcutPath%'); $Shortcut.TargetPath='%targetPath%'; $Shortcut.IconLocation='%iconPath%'; $Shortcut.WorkingDirectory='%workingDirectory%'; $Shortcut.Description='%shortcutTargetDescription%'; $Shortcut.WindowStyle=%windowStyle%; $Shortcut.Save()"
)
echo The operation is complete. & echo. & pause