Run same program multipe times via batch file or PowerShell


  1. Posts : 7
    Win10
       #1

    Run same program multipe times via batch file or PowerShell


    I'm not sure if I am posting in the correct forum - if wrong, please forgive me.

    Is it possible to open a program twice with different names? The reason I ask is I have a screen widget (digital clock) that I want displayed in a couple locations on my desktop depending on what’s running. I only want it displayed a second time when one program is running (Spotify).

    So, first off, the clock would be displayed upon boot in one specific location and permanently remain in that location. I was hoping to write a small batch file or something that reloads the clock program in a different location before it opens Spotify. Then, upon closing Spotify, the second instance of clock would be closed leaving the original instance still in place.

    I have been able to do this manually – that is, open D_Clock.exe twice and manually close the second instance. However, I’d like to do this via some routine. I understand batch files and simple PowerShell routines. I also have a Bat2Exe program that creates an executable from a batch file.

    Any suggestions would be appreciated.
      My Computer


  2. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #2

    If your clock application is happy to run twice then you can run it twice using a batch file. No problem at all.
    But batch files cannot readily control the position of your clock on the screen [if at all]. Is that something that you have managed to achieve in your manual experiments just using settings in the clock application itself?
    How did you distinguish between the two instances of your clock when you closed one of them? It might be worth checking how they are shown in Task manager, Processes including making Task mgr display the Command line column [right click on an existing column header and select Command line].

    By the way, those Bat2Exe utilities are rarely worth bothering with.
    All they do is store a copy of the batch inside then, when you run the exe, it extracts the batch file and runs it. You might just as well run the batch file yourself and cut out the interference.


    PowerShell is more sophisticated and can apparently set window sizes & positions although I haven't experimented with this myself.
    You need to attain a degree of PowerShell capability to make use of this guidance - PS Set the position and size of a Window - TechNet They seem to have reorganised their site and moved/deleted that article. I've attached pdf printouts of the article together with a ps1 file of their suggested PS Function.
    PS Set the position and size of a Window.zip


    You might wish to study my ditty Batch file and PowerShell guides [post #16] - TenForums



    Denis
      My Computer


  3. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #3

    You ought to have said that you had asked this question in two different forums. Your question had already been answered before I spent time & effort on you.
    Run program multiple times via batch file or powershell | Windows 11 Forum

    Denis
      My Computer


  4. Posts : 7
    Win10
    Thread Starter
       #4

    Try3 said:
    You ought to have said that you had asked this question in two different forums. Your question had already been answered before I spent time & effort on you.
    Run program multiple times via batch file or powershell | Windows 11 Forum

    Denis
    Thank you Denis for your time. I have been able to get the clock to appear in two different locations which is great. My problem is how to close only one of the open instances (i.e., the one that opens with Spotify). I thought by creating an EXE via the Bat2Exe program and giving the it a new name I could then close the clock with the new name but apparently even though I changed the name of the EXE the computer still thinks it has it's original name.

    Sorry about the double post by my past experience has proven that posting in multiple forums works out much much better.
      My Computer


  5. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #5

    esskaykay said:
    Sorry about the double post by my past experience has proven that posting in multiple forums works out much much better.
    I wasn't bothered by the double posting but by your failure to state that you had done so. I simple link in each thread would have enabled everybody to see what had already been said.

    What do the two instances of your clock show in Task mgr? Any difference?
    Do both instances show the same Titles in their TitleBars [if they have them] or in the popup on their Taskbar icon]?
    e.g.
    Run same program multipe times via batch file or PowerShell-titlebars.png
    and
    Run same program multipe times via batch file or PowerShell-taskbar-popups.png

    Is one of them consistently the second one to be started? If so there might be a chance of using tasklist / taskkill commands to do what you want.

    Why do you want to do all this anyway?


    Denis
      My Computer


  6. Posts : 7
    Win10
    Thread Starter
       #6

    Try3 said:
    I wasn't bothered by the double posting but by your failure to state that you had done so. I simple link in each thread would have enabled everybody to see what had already been said.

    What do the two instances of your clock show in Task mgr? Any difference?
    Do both instances show the same Titles in their TitleBars [if they have them] or in the popup on their Taskbar icon]?
    e.g.
    Run same program multipe times via batch file or PowerShell-titlebars.png
    and
    Run same program multipe times via batch file or PowerShell-taskbar-popups.png

    Is one of them consistently the second one to be started? If so there might be a chance of using tasklist / taskkill commands to do what you want.

    Why do you want to do all this anyway?


    Denis
    Hey Denis,

    I did get the taskkill to work. I can close each instance independently, so I’m getting closer.

    The reason I’m looking for this is I (and my band mates) like playing along to songs on Spotify (I’m a drummer). When practicing, and viewing Spotify, I like seeing the clock in a different location and color making it more visibly apparent. However, when not drumming or listing to Spotify on the “Drum PC”, I do not want the clock in such a dominating position. I have it permanently positioned over the task bar. I am running Win10 on an older HP laptop.

    I am still looking at a few other configuration, setup, and run routines. I have contacted the developer of the program but to honest, I don’t think this program is still supported as there have been no enhancements in a few years. However, if I can get this open/close/position/color thing to work, I would be satisfied (at least for now).

    I’ll keep you posted as I learn more.

    Again, thanks for your time and consideration – much appreciated,
    Steve K.
      My Computer


  7. Posts : 6,850
    22H2 64 Bit Pro
       #7

    Why not run a couple of portable clocks then?

    Run same program multipe times via batch file or PowerShell-clocks.jpg

    I have DS Clock (Portable) set to start with windows and place it on the taskbar. If I want another clock I use a portable vector clock and move it wherever I want.
      My Computer


  8. Posts : 7
    Win10
    Thread Starter
       #8

    Callender,

    Thank you very much for your suggestion. Prior to reading your post, I contacted the developer and he got back to me (which was very surprising and well appreciated since he no longer supports this app) with the same suggestion – use the portable version. I did so and now I can open and close each instance independently.

    Again, my since thanks to you both (Try3 and Callender) for your assistance. This is most certainly more than I expected.
    Steve K.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:39.
Find Us




Windows 10 Forums