How to Add a Program to the Start Menu in Batch Script
When installing custom software, deploying IT tools, or organizing a workstation, adding shortcuts to the Windows Start Menu is a standard requirement. In this guide, we will explore how to add programs to the Start Menu using Batch Script. Because the Start Menu is simply a collection of folders containing shortcuts, this task combines working with Windows environment variables and programmatically creating .lnk files.
This technique is essential for system administrators, developers, and power users who want to automate their setup environments smoothly and professionally.
Understanding Start Menu Locations
The Start Menu in Windows is built by combining shortcuts from two different directory locations:
- Current User Start Menu: Only visible to the person currently logged in.
- Path:
%APPDATA%\Microsoft\Windows\Start Menu\Programs
- Path:
- All Users Start Menu: Visible to every user on the computer. Modifying this requires Administrator privileges.
- Path:
%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs
- Path:
When adding a program, you must decide whether it should be available just for you or for everyone.
Method 1: Adding a Shortcut for the Current User
Because this only affects your profile, it does not require administrative rights.
Since Batch Script cannot create .lnk shortcut files natively, we use a helper script in VBScript to interface with the WScript.Shell COM object.
@echo off
setlocal
:: Define the target application and shortcut location
:: Note: Windows instantly hides new Start Menu shortcuts if the target file does not natively exist!
:: We use Notepad here so the shortcut successfully appears as a valid application.
set "target=%windir%\System32\notepad.exe"
set "start_menu=%APPDATA%\Microsoft\Windows\Start Menu\Programs"
set "shortcut=%start_menu%\My Custom App.lnk"
echo Creating Start Menu shortcut for current user...
:: Create the shortcut securely bypassing VBScript and CMD block string issues
powershell -NoProfile -Command "$ws = New-Object -ComObject WScript.Shell; $sc = $ws.CreateShortcut('%shortcut%'); $sc.TargetPath = '%target%'; $sc.Description = 'Launch My Custom Application'; $sc.Save()"
echo [OK] Shortcut natively added to Start Menu.
pause
Method 2: Adding a Shortcut for All Users
If you are a system administrator deploying a tool for all employees on a workstation, you must add it to the All Users directory.
Checking for Admin Rights
Because %PROGRAMDATA% is a protected system directory, your Batch script must check if it is running as an Administrator before attempting to create the shortcut.
@echo off
setlocal
:: Verify Administrator privileges
net session >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Must run as Administrator to add a program for All Users.
pause
exit /b 1
)
:: Note: Start Menu directories universally hide shortcuts if the target file does not exist.
:: We target the native Ping tool so the link validates and appears correctly!
set "target=%windir%\System32\ping.exe"
set "start_menu=%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs"
set "shortcut=%start_menu%\Network Pinger.lnk"
echo Creating generic Start Menu shortcut for All Users...
:: Dynamically construct the shortcut bypassing fragile VBScript multiline output constraints
powershell -NoProfile -Command "$ws = New-Object -ComObject WScript.Shell; $sc = $ws.CreateShortcut('%shortcut%'); $sc.TargetPath = '%target%'; $sc.Save()"
echo [OK] Shortcut created successfully.
pause
Method 3: Grouping Shortcuts in a Subfolder
For software suites or multiple tools, dropping individual shortcuts into the root of the Start Menu is poor practice. The professional approach is to create a subfolder (e.g., "Company IT Tools") and place the shortcuts inside it.
@echo off
setlocal
:: Note: Dead shortcut hiding applies to subfolders as well!
:: We use native system apps here to ensure the folder is fully visible natively.
set "target1=%windir%\System32\cmd.exe"
set "target2=%windir%\System32\WindowsPowerShell\v1.0\powershell.exe"
:: Define the subfolder path
set "sm_folder=%APPDATA%\Microsoft\Windows\Start Menu\Programs\My Tool Suite"
:: Create the directory if it doesn't exist
if not exist "%sm_folder%" (
mkdir "%sm_folder%"
echo Created folder: My Tool Suite
)
:: Create shortcuts inside the subfolder bypassing CMD parenthesis defects
powershell -NoProfile -Command "$ws = New-Object -ComObject WScript.Shell; $sc1 = $ws.CreateShortcut('%sm_folder%\Tool A.lnk'); $sc1.TargetPath = '%target1%'; $sc1.Save(); $sc2 = $ws.CreateShortcut('%sm_folder%\Tool B.lnk'); $sc2.TargetPath = '%target2%'; $sc2.Save()"
echo [OK] Suite added to Start Menu.
pause
Common Mistakes
The Wrong Way: Using the COPY Command for Executables
:: WRONG - Do not put raw executables in the Start Menu
copy "C:\Tools\MyTool.exe" "%APPDATA%\Microsoft\Windows\Start Menu\Programs\"
Output Concern:
While the program will appear in the Start Menu, placing raw .exe files there pollutes the directory, often causes working directory issues when launched, and looks unprofessional. Always use .lnk shortcuts.
The Correct Way: Use VBScript or PowerShell
Always generate a .lnk file pointing to the actual install location of the executable, as demonstrated in the methods above.
Using PowerShell as an Alternative
If you prefer not to use VBScript, the same COM object is accessible via PowerShell natively in Windows 10 and 11.
@echo off
set "target=C:\Windows\System32\notepad.exe"
set "shortcut=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Quick Notepad.lnk"
powershell -command ^
"$ws = New-Object -ComObject WScript.Shell;" ^
"$sc = $ws.CreateShortcut('%shortcut%');" ^
"$sc.TargetPath = '%target%';" ^
"$sc.Save()"
echo [OK] Shortcut created via PowerShell.
pause
Windows 10/11 Pinning vs. Adding
It is important to understand the difference between adding to the Start Menu and pinning to the Start Menu tile/grid area:
- Adding to the "All Apps" List: The techniques in this guide place the app in the alphabetical "All Apps" list. This works perfectly via Batch.
- Pinning to the Grid/Tiles: Microsoft restricts programmatic pinning to the prominent tile/icon grid to prevent abusive software from spamming the user interface. Pinning to the grid usually requires user interaction, Group Policy (via Start Layout XML), or complex, undocumented registry hacks that change frequently between OS updates.
Best Practices
- Always use environment variables (
%APPDATA%,%PROGRAMDATA%) instead of hardcoded paths likeC:\Users\Username. - Organize into folders if you are installing more than two tools.
- Check for Admin rights if you intend to modify the All Users scope.
- Set WorkDir and Icons: Consider actively setting
sc.WorkingDirectoryandsc.IconLocationduring the shortcut creation if the program relies on supporting files.
Conclusion
Adding a program to the Windows Start Menu via Batch Script is a reliable process involving the programmatic creation of shortcut files in specific system directories.
By utilizing VBScript or PowerShell helper strings within your Batch code, you can ensure that custom tools, deployment packages, and administrative scripts are flawlessly integrated into the user's standard Windows interface.