Putting BAT on Taskbar or inserting it to Tray

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
DOSadnie
Posts: 144
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Putting BAT on Taskbar or inserting it to Tray

#1 Post by DOSadnie » 09 Aug 2023 05:53

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
Last edited by DOSadnie on 22 Sep 2023 00:49, edited 1 time in total.

OJBakker
Expert
Posts: 93
Joined: 12 Aug 2011 13:57

Re: Putting BAT on Taskbar or inserting it to Tray

#2 Post by OJBakker » 09 Aug 2023 08:48

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.

Aacini
Expert
Posts: 1920
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Putting BAT on Taskbar or inserting it to Tray

#3 Post by Aacini » 10 Aug 2023 16:56

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

DOSadnie
Posts: 144
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Re: Putting BAT on Taskbar or inserting it to Tray

#4 Post by DOSadnie » 11 Aug 2023 02:44

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?

DOSadnie
Posts: 144
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Re: Putting BAT on Taskbar or inserting it to Tray

#5 Post by DOSadnie » 20 Jan 2024 03:51

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?

Post Reply