Bob J Jones
2018-05-28 18:31:02 UTC
*For noobs*: Step by Step, how to make a Hello World batch script *AND* put
it in both the Win10/7 Start Menu & Task Bar (which isn't intuitive!)
*For experts*: Please note this need is actually related to the VPN DOS
killswitch, but this simple Hello World example exemplifies the same
*Thread Goal*: Add a batch file shortcut to BOTH the Win10/7 StartMenu & TaskBar.
HINT: If you think it's intuitive, then you are already an expert. :)
Normally you just right-click and select "Pin to Start", but that option
doesn't exist in the right-click menu of my batch-file.lnk shortcut above.
Normally you just slide the program shortcut onto the task bar, but that
method doesn't work with my batch-file.lnk shortcut above.
STEP-by-STEP cut-and-paste instructions for noobs follow.
(Experts: Please improve the process.)
Here is how to reproduce the problem & solve it on a Windows 10/7 machine.
1. Create any batch file, e.g., this hello.bat file, in your script folder:
@echo Hello world.
NOTE: The problem arose in the vpnkillswitch batch file, where this
Hello World is a simple example that exemplifies the problems.
2. Rightclick to "Create shortcut" & move the shortcut to the desktop.
Note: It doesn't matter where you put the shortcut; the desktop is easy.
3. After testing that the shortcut works, try to put it in the Start menu.
(Right clicking does NOT have a "Pin to Start" option!) Yet! :)
4. Try to slide it onto the Windows 10 Task Bar.
(Left clicking and sliding onto the Task Bar does nothing.)
5. Google for how to put a batch shortcut in the Start Menu or Task Bar:
How to Organize and Add Shortcuts to the All Apps List on Windows 10
A. Copy your shortcut to either of these two locations.
%appdata%\Microsoft\Windows\Start Menu\Programs\ <-- for just the user
%programdata%\Microsoft\Windows\Start Menu\Programs\ <-- for all users
B. The shortcut appears in your alphabetical (left side) Win10 Start Menu.
(This is important to note since once it's in the left side, it can
be added to the right side, and later on, you'll see a belated easier
method to put the shortcut ONLY in the right side, but not the left
C. Rightclick on *that* left-side StartMenu entry & select "Pin to Start".
This now puts the shortcut also in the right side of the Start Menu.
D. But that shortcut still won't slide into the task bar.
E. Google for the location of the task bar directory so you can just drop
the shortcut into that directory, but you find that the Task Bar location
is apparently a registry entry? So I gave up on that approach (but it might
have worked - I don't know.)
F. Google some more, and you find this for Windows 7 & 10.
How to pin a batch file to the taskbar in windows 7
G. It says to create a "command prompt" shortcut & change the target to:
%windir%\system32\cmd.exe /c "C:\bin\hello.bat"
But what works as well is to just take the original "hello.bat.lnk"
shortcut and just change its target to that line above.
H. Once I do that, I can now simply slide that shortcut into the Taskbar!
Even easier, I can now rightclick on that shortcut to "Pin to Taskbar".
I. But now, when I run the batch command, it pops up and then dies.
J. I then look at the meaning of the suggested option of "/C":
/C = Carries out the command specified by string and then terminates
So I remove that "/C" option, but then the shortcut just opens a
command window in the "Start in" directory (which is useless).
K. I then look at the meaning of the suggested option of "/K":
/K = Carries out the command specified by string but remains
I replace the "/C" option with the "/K" option & it now works.
%windir%\system32\cmd.exe /K "C:\bin\hello.bat"
L. Belatedly, I noticed that the "Pin to Start" suddenly exists:
So, maybe I didn't need to do all that Start Menu stuff above!
(But it only added a tile, and not an alphabetical entry.)
This explains, to a noob, like I am, how to:
I. Create a batch command that stays up (like the killswitch!)
II. Add that batch command to both sides of the Start Menu
III. Add that batch command to the Windows Task Bar
As always, if you have improvements, please state them, because this is
intended to be a working reference for people who implement the VPN
killswitch to follow successfully.