Discussion:
For noobs: How to make a Hello World batch script *AND* put it in both the Start Menu & Task Bar (which isn't intuitive!)
(too old to reply)
Bob J Jones
2018-05-28 18:31:02 UTC
Permalink
Raw Message
*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
problems!
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/56KgMK6n090/xdRDoSKFAQAJ>

*Thread Goal*: Add a batch file shortcut to BOTH the Win10/7 StartMenu & TaskBar.
Loading Image...
HINT: If you think it's intuitive, then you are already an expert. :)

START MENU:
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.

TASK BAR:
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 off
:loop
@echo Hello world.
@pause
goto loop
exit

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! :)
Loading Image...

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
<https://www.howtogeek.com/225654/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
side.)

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
<https://mattrefghi.com/blog/2012/06/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.
Loading Image...

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".
Loading Image...

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":
cmd.exe /?
/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).
%windir%\system32\cmd.exe "C:\bin\hello.bat"

K. I then look at the meaning of the suggested option of "/K":
cmd.exe /?
/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:
Loading Image...
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.)

Voila!

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.
<https://groups.google.com/d/msg/microsoft.public.windowsxp.general/56KgMK6n090/xdRDoSKFAQAJ>
Bob J Jones
2018-05-28 21:34:32 UTC
Permalink
Raw Message
Post by Bob J Jones
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
The next step is to change the icon so that it looks different from the
normal black command-window icon.

This is especially important in your task bar with small icons or in your
Start Menu with small icons.
Loading Image...

Here is the vpn killswitch shortcut icon switched to a scissors icon:
Loading Image...

So that the shortcut could be easily pinned to both the Start Menu (right
side only) and to the taskbar, I first had to change the shortcut Target:
FROM: C:\bin\vpnkill.bat
TO: %windir%\system32\cmd.exe /K "C:\bin\vpnkill.bat"
Loading Image...

And then I set the "Change icon" "Look for icons in this file" field
FROM: C:\Windows\System32\cmd.exe
TO: %SystemRoot%\System32\SHELL32.dll
Loading Image...

Only after that can you choose any of about a hundred or so icons inside
that SHELL32.dll file to use in order to distinguish your vpn killswitch
shortcut from any other batch-file shortcut icon.
--
NOTE above that hello.bat & vpnkill.bat are interchangeable, since the
former is just a simple example of the latter.
Loading...