How to pin to start menu using a batch file (Windows 10) - batch-file

I need to pin an executable into the new Windows 10 start menu (i.e. creating a tile).
I'm aware of PowerShell scripts that do the job, but I need some instructions to add at the end of an existing batch file (cmd) we already use for installing our applications.
The usual scripts (valid for Windows 8 and 8.1) simply don't work. How can I do this?

This is a kludge work around that Microsoft needs to fix, but it worked for me.
Temporary rename the .bat file to .exe. Then right click on the file name. It will give you the Pin to start option. Pin it to the start menu. It won't work, but there is an option open the file location. Select that and change the name back to .bat. Now it works.

The way it works on Windows 10 after trying almost 15 different methods that didn't work for me
Go to your desktop -> right-click -> Create New Shortcut
In the shortcut target type the following text:
cmd /c "full path to your batch file"
It will look something like this:
cmd /c "C:\Users\Jmeter\Desktop\jmeter.bat"
Name the shortcut.
Right-click on the shortcut -> select Pin to taskbar. If you'd prefer it pinned to your Start menu, select Pin to start instead.
Bonus: Download some .png image -> Go here (https://icoconvert.com/) -> convert to Windows icon file -> set as new icon

Note: I've wrote and tested this on windows 8 - you might face issues on windows 10.
Check this. This a JScript/bat hybrid that uses the shellapplication object and invokeverb function (i.e. emulates right click and chooses some specific actions). It is now compatible with Windows 10.
Use it like this (you can use also a shortcut/.lnk to an exe):
call pinnerJS.bat "%windir%\system32\cmd.exe" startmenu

Follow my original method, and you will get .bat file{s} pinned in Taskbar. WORKS 100%
Step 1: Create shortcut of your .bat file (for example in Desktop “C:\Users\youruser\Desktop\yourfile.bat”). So you will end up with “yourfile.bat – Shortcut.lnk” (you might not see extension “.lnk”).
Step 2: Right Click your shortcut and change your Target field from: “C:\Users\youruser\Desktop\yourfile.bat” to: explorer “C:\Users\youruser\Desktop\yourfile.bat” – note: explorer is the explorer.exe app. You can also write the full Path: C:\Windows\explorer.exe, for no confusion.
Step 3: Now Right Click your shortcut and now you can see the option Pin to Taskbar.
Step 4: Right Click the pinned shortcut, and you will see two options: shortcut itself and unpin option. Right Click the shortcut and select Properties. From Target field delete “C:\Windows\explorer.exe” and leave only “C:\Users\youruser\Desktop\yourfile.bat”, and click OK
Now you can delete your shortcut in Desktop, since now you have your standalone shortcut on Taskbar
Optionaly, if you want to change Icon do Step 4, but now click “Change Icon…” button, and choose your custom Icon, from some other exe file or .ico file.
That’s it!
Now you have fully functional batch file shortcut on Taskbar

Right now, you can't do this with free tools (maybe Windows want to get into the "pay2tile" business model).
One possible option at the moment would be to use Classic Shell.

Related

'gcc' is not recognized - How to make gcc/mingw work in Windows?

The Mingw binary installation instructions (such as these) tells me to change the PATH environment variable in Windows, in order to use the gcc/g++ etc commands anywhere. This might also be necessary for some programming IDE to find the compiler. Failing to do so yields errors such as this:
'gcc' is not recognized as an internal or external command, operable program or batch file.
How do I do this specifically in newer versions of Windows (10/11) and which path should I use?
Right-click "My Computer"/"This PC" from Windows explorer and pick properties. Alternatively Windows key + X and click "System". An "About" window appears.
Scroll down to "Advanced system settings" and click on it.
Click on the "Environment Variables" button.
Select "Path" in the window that appears and click the edit button.
Click on "Edit text" (not on "Edit"!).
Before modifying anything, I strongly recommend to copy the text there and save it in a text file for backup, so that you can restore the PATH in case of mistakes.
Write a semicolon ; at the end of the text there unless already present. Then after the semicolon add the full path to your Mingw installation's bin folder. For example ;c:\mingw_w64\bin.
Important: if you installed Mingw under for example C:\program files\mingw_w64, then the path must be ;C:\Program Files\mingw-w64\bin; without any surrounding " ... ". If using the "Edit" command available in this window, then the " ... " will get added and this may break the gcc path from working. (It just happened to me and that's the reason why I decided to write this Q&A.)
Click OK for each open window.
Reboot Windows.
Now you should be able to type gcc from the command line or use it from your programming IDE.
Alternatively, for CLI users:
Open cmd.
Type PATH.
Add the absolute path to the bin folder to it.
Place a semi-colon at the end.
Press enter.
Reboot.
And you're done.
Edit: For the full path to the bin folder:
cd your way to Mingw installation's bin folder, or alternatively, press windows key + e.
Open mingw -> bin.
Copy the full path present in the search bar.
As #Lundin said, you should first make a copy of the original PATH and save it, just in case something goes wrong.

Open multiple Microsoft Edge windows from batch file

I need to open 2 Edge windows from a batch file (not two tabs, 2 windows). I know I can launch edge using the following command:
start microsoft-edge:
But if I try it twice the second command does nothing. If I try it with URLs I get 2 tabs in the same window. e.g.
start microsoft-edge:http://google.com
start microsoft-edge:http://bing.com
Any ideas how to get 2 separate windows?
Use --new-window option:
start msedge http://google.com
start msedge --new-window http://bing.com
As you are aware, you can trigger Microsoft Edge indirectly from the command line (or a batch file) by using the microsoft-edge: protocol handler. Unfortunately, this approach doesn't enable you to open up an arbitrary number of windows.
The Microsoft Edge team built a small utility to assist, and presently hosts it on GitHub.
> MicrosoftEdgeLauncher.exe http://bing.com
> MicrosoftEdgeLauncher.exe http://stackoverflow.com
I just tested this, and it opened two individual windows for me. There does appear to be an issue where the second window doesn't navigate to the URL; remaining open with the New Tab Page.
You can open as many as you like, just create batch files that call other batch files.
Very easy to do.
Ex: batch1.cmd:
#echo off
start microsoft-edge:http://google.com
start "path\batch2.cmd"
exit
Make sure to add "start microsoft-edge:http://bing.com" on your "batch2.cmd" file
Manny
You can use the executable msedge_proxy.exe which is installed alongside msedge.exe. For example in "C:\Program Files (x86)\Microsoft\Edge\Application".
Sample usage:
> msedge_proxy.exe --app=http://bing.com
If you execute that command multiple times, it pops a new window each time.

How to open cmd and execute command using bat file?

As i am new to JAVA programming, I used to compile and run classes using Command Prompt. But I am lazy to open and set paths every time in CMD. I found that can set the folder's path automatically using a batch file by placing it in the folder that i want to specify. But I dont know how to set the path of the jdk bin folder using bat file.
I just typed set path=%path%;C:\Program Files\Java\jdk1.8.0\bin but no hope.
So please can you guys tell me what is the code for do that. Thank you.
Assuming that
(1) You want to set path to JDK bin AND (2) the path must be available even after the batch file terminates.
In such a case, please consider setting it this way:
https://java.com/en/download/help/path.xml
Windows 8
Drag the Mouse pointer to the Right bottom corner of the screen
Click on the Search icon and type: Control Panel
Click on -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Close the window.
Reopen Command prompt window, and run your java code.
Windows 7
Select Computer from the Start menu
Choose System Properties from the context menu
Click Advanced system settings > Advanced tab
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Reopen Command prompt window, and run your java code.
Windows XP
Start -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Close the window.
Reopen Command prompt window, and run your java code.
Windows Vista
Right click My Computer icon
Choose Properties from the context menu
Click Advanced tab (Advanced system settings link in Vista)
In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Reopen Command prompt window, and run your java code.
UPDATE: Quoted from website, as per suggestion by #Brian Tompsett

How to make a new file with the windows context menu

Using the registry I used the following code below to create a sub-menu in the windows context menu.
[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Power Menu]
"MUIVerb"="Matt's Usefull Tools"
"SubCommands"="batmode;logoff;switch;sleep;hibernate;restart;safemode;shutdown;hybridshutdown"
"Icon"="C:\\Users\\Matthew\\Downloads\\Hacker.ico"
"Position"="bottom"
Now I want to be able to click a command I set and then have it create a .bat file where I right clicked, I know you can add this to the "New" sub menu by editing the ".bat" registry using the code.
[HKEY_CLASSES_ROOT\.bat\ShellNew]
"NullFile"=""
Now is it possible to implement this into my sub-menu?
i could get this only to work w/ following command:
CMD.exe /c #ECHO.>"%V\New File.bat"
Under HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\Shell\batfile\command
where "batfile" must be one of your "SubCommands".
the issue is, that this will always create the "New File.bat" in current location (e.g. Desktop).
If there's an existing "New File.bat" it will just overwrite it.
If you use CMD.exe /c #ECHO.>>"%V\New File.bat" and there's an existing copy of "New File.bat", it will just add whitespace to the file.
i do not know a way to Call "ShellNew" from "command". :/
Maybe it helps anyway.
Edit:
whoops... just saw that this is an one year old question ^.^
anyway - it may help somebody else. :)

trouble with cake.bat

I am new to php and cake php. I am attempting to bake up some cakephp code in the Windows Command Prompt. When I do the command "cake bake" within C:\xampp\htdocs\cake\lib\Cake\Console, I get no result, just a blinking cursor. Has anyone else ever had this happen or have any suggestions that might be helpful?
Go to the dir C:\xampp\htdocs\cake\app.
I don't know which version of Windows you have. However, you must access Environment Variables Access it by any mean.
In Windows7:
Right Click on Mycomputer-> Properties -> click on Advanced System Settings -> The last button Environment Variables is there, click on it From System Variables list select Path and then press Edit button. You will see a line of code, at its end add something like the following:
;C:\xampp\htdocs\cakephp\cake\console\;C:\xampp\php
The first path is the path in-which cake.bat file is found
The second path is the path in-which php.exe is found.
Restart your coputer and you will find cake bake works fine at any directory you want.

Resources