Page 1 of 1

Putting BAT on Taskbar or inserting it to Tray

Posted: 09 Aug 2023 05:53
by DOSadnie
Is there a way to pin to Taskbar of Windows 10 a BAT file or an LNK leading permanently to it? Or to insert either of them to the Tray notification area?

I tried pinning to Taskbar the cmd.exe and then setting its Target to

Code: Select all

C:\Windows\System32\cmd.exe "C:\MY SCRIPTS\test.bat"
but it just opens CMD window with a prompt in

C:\Windows\System32>


I do not want to compile BAT to an EXE and I cannot use other script to run this BAT

Re: Putting BAT on Taskbar or inserting it to Tray

Posted: 09 Aug 2023 08:48
by OJBakker
One way that seems to work:

Go to the location of your batchfile in explorer.
Right click on your batchfile: click Create Shortcut.
Now you have a shortcut with the correct batchfile and starting directory.
The only problem is this is implicit started by the cmd.exe.
Next step is make this start explicit.
Right Click on the Shortcut, go to Properties.
Change the Target field by prefixing the existing command with "%ComSpec% /c " (without the surrounding double quot's)
and save the changes.
Start the shortcut. This will start the batchfile and it appears in the taskbar.
In the taskbar right click and select "Pin to taskbar".
Close your batchfile.
The link remains pinned to the taskbar.
Start the link from the taskbar and your batchfile will run again.
If you later make changes to your shortcut you will probably have to unpin the old one and make a new pin to the shortcut.

Re: Putting BAT on Taskbar or inserting it to Tray

Posted: 10 Aug 2023 16:56
by Aacini
DOSadnie wrote:
09 Aug 2023 05:53
Is there a way to pin to Taskbar of Windows 10 a BAT file or an LNK leading to it? Or to insert either of them to the Tray notification area?

I tried pinning to Taskbar the cmd.exe and then setting its Target to

Code: Select all

C:\Windows\System32\cmd.exe "C:\MY SCRIPTS\test.bat"
but it just opens CMD window with a prompt in

C:\Windows\System32>


I do not want to compile BAT to an EXE and I cannot use other script to run this BAT
You just missed the /C switch in cmd.exe:

Code: Select all

C:\Windows\System32\cmd.exe /C "C:\MY SCRIPTS\test.bat"
Enter cmd /? for further details.

Antonio

Re: Putting BAT on Taskbar or inserting it to Tray

Posted: 11 Aug 2023 02:44
by DOSadnie
OJBakker wrote:
09 Aug 2023 08:48
[...]
"%ComSpec% /c "
[...]
Aacini wrote:
10 Aug 2023 16:56
[...]
You just missed the /C switch in cmd.exe:
[...]
Yes, the problem was omission of

Code: Select all

/c
in-between; thank you both

However there is also caveat: I must run also run is as Administrator in order for it to push through its commands [of closing of various processes]


How about moving it to the Tray area? Does any one have ideas on how to do it?

Re: Putting BAT on Taskbar or inserting it to Tray

Posted: 20 Jan 2024 03:51
by DOSadnie
DOSadnie wrote:
11 Aug 2023 02:44
[...]
How about moving it to the Tray area? Does any one have ideas on how to do it?
Any ideas about how to insert a script into the Tray and make it stay there as an always accessible icon?