Station automation: starting and exiting multiple programs





Ham radio computers usually run a lot of different applications. This is like my desktop looks these days.  Yes, I use a 55 inch cheap 4k  TV as computer monitor.  I can only recommend this..


I got tired of launching them manually, and forgetting something. I used DXLab’s Launcher for a while. When I found some things that could not be done with it, I wrote my own batch scripts. Remember the old autoexec.bat? Exactly. 🙂

A little later, I wanted to launch a couple other programs in a different order.

Even later, I had a program that needed some time to finish launching, before the next program could be started.

Then it got too difficult to do this in batch scripting. I switched to Windows PowerShell. This turned out to be a good move.  Things got easier from then on.

Then I realized, I was even too lazy to log into Windows. Typing my password was the last thing that separated me from pushing the power button on the computer and having everything neatly open on the desktop.

Below I explain how to do set it up and use it. I share the tool, use it, share it, change it. So, if you are interested, read on. If you find bugs, let me know.

When you are all done, you will have at a minimum 2 shortcuts on your Windows desktop. One is to launch and one is to close all your applications (1 and 2 in the illustration below).

Note: I used to leave my computer on all the time because it was so much effort to launch everything. With the ideas presented here, it is so simple that I now turn the computer off almost every day. My shack is only 14 x 7 feet, so it heats up quickly if I keep a computer running all the time. And off course, it feels good to conserve energy.

Optional: How to automatically log into Windows

Do you want Windows automatically log you in when you turn it on? Its fully supported by Windows. Before you do it though, consider the security implications. Only do this with a personal computer and if you can trust the people that have access to your computer.

To set this up, simply follow the steps in this blog: Automatically log in to your Windows 10 PC.

List the programs to be launched

As a next step, you should take stock of everything you want to launch. Sometimes the order matters as well. The below file launches everything I need to operate my radio for rag-chewing or contesting (yours will look different, for sure. But you can get the idea how this works by inspecting mine). It launches everything I need to operate on my radio or run in a contest:

"C:\Program Files\FlexRadio Systems\SmartSDR v2.3.9\SmartSDR CAT\Cat.exe" /MIN
"C:\Program Files\FlexRadio Systems\SmartSDR v2.3.9\DAX\Dax.exe" /MIN
"C:\Program Files (x86)\UTC - World Clock\UTC - World Clock.exe"
;;;;;;;;;;"C:\DXLab\Launcher\DXLabLauncher.exe"
"C:\DXLab\Commander\CI-V Commander.exe"
"C:\DXLab\DXKeeper\DXKeeper.exe"
"C:\DXLab\DXView\DXView.exe"
"C:\Program Files (x86)\N1MM-DXKeeperGateway\N1MM_DXK_GW.exe"
"C:\Program Files (x86)\PABridge\PABridge.exe"
"C:\Program Files (x86)\Green Heron Engineering\GH Everyware Server\GH Everyware Server.exe"
"C:\Program Files (x86)\Green Heron Engineering\GH Everyware Client\GH Everyware Client.exe"
"C:\Program Files (x86)\Aggregator\Aggregator.exe" /MIN
"C:\Program Files (x86)\Elecraft\W2 Meter\W2.exe"
"C:\Program Files (x86)\PstRotatorAz\PstRotatorAz.exe"
"C:\Program Files (x86)\VOAProp\VOAProp.exe"
"C:\Program Files (x86)\wintelnetx_4_22\wintelnetx.exe" -start ini\MySkimmer_plus_W9PA_to_localhost23.ini
"C:\Program Files (x86)\FRStack\FRStack.exe"
"C:\Program Files (x86)\slice-master-6000-v0.10.5dUpdate\slice-master.exe" --window-minimized 1
"C:\Program Files\TightVNC\tvnviewer.exe" -optionsfile=C:\Users\andre\Documents\RF2K+VNCConnection.vnc
"C:\Program Files (x86)\N1MMLogger+\N1MMLogger.net.exe"

You may want to start with a file with just one or two programs registered. You can always add more when you got the script running.  Put each executable on one line in a text file. The full path must be in double quotes. Parameters are supported.  The order you put in the entries is the order the programs are going to be started.

Save the file at a convenient place. I suggest you put it somewhere in your Documents folder. I saved mine at C:\Users\andre\Documents\hamapps1.txt (%userprofile%\documents\hamapps1.txt for Windows Vista and later).

The script

Follow these steps to get the script:

  • Download the zipped up script from here AppAutomation
  • Unblock the zip file. Follow these steps: https://blogs.msdn.microsoft.com/delay/p/unblockingdownloadedfile/.
  • Now, unzip the file and save the AppAutomation.ps1 file right next to the text file you saved earlier.
  • In case you need to unblock the ps1 file too, do this now.

Create a shortcut to launch the applications

Right click your Windows desktop, and choose “Create a Shortcut” and type PowerShell.exe.

Hit the Next button. Then type in a good name. I called mine “StartApps”.  Then hit Finish.

Now we have a shortcut, but we need to hook it up with our script and text files.  So, open the shortcut (Right mouse click and choose Properties).

Update the Target by adding the text after the PowerShell.exe:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass %userprofile%\documents\AppAutomation.ps1 -launchOrExit $true -applicationsFilePath %userprofile%\documents\hamapps1.txt

In this shortcut, we see a couple of arguments:

  • -ExecutionPolicy is something we need for Powershell.
  • -launchOrExit tells it whether we launch ($true) or exit ($false)
  • -applicationsFilePath indicates where the text file is located.

Update the shortcut to run as Adminstrator.

Now, try it out. Double click the shortcut. Windows will pop up a UAC prompt, hit OK, and you should see your script run.

If you run it again, you will find that the script will only launch the programs that are not started yet. If all are still running, it will not do anything.

Create a shortcut to close the applications

Make a copy of your shortcut you just created.  Right click, Properties: In the Target box, change the parameter -launchOrExit to $false.  In the General tab give it a better name, i.e. “CloseApps”.

Try it out.  The execution of the script should now close the same apps you started earlier.

If you are happy with the shortcuts, all you need to do now is fine-tune your text file to add more programs.

If you need a delay after some programs, add DELAY_IN_SECONDS XX where XX are the seconds you need to delay the script at that point of execution.

If you need a program window to be minmized, add /MIN as an argument.

Putting it all together, total automation

If I did not lose you somewhere above and you got everything working, you now get automatically logged in and you have a desktop shortcut to launch everything you need.

Well, we can do better than that! 🙂 We can combine both, and run the script on logon as well. Your decision if this makes sense for you or not.  We can use the Windows Task Scheduler for that. Here is how you do it:

  • Launch the “Task Scheduler”
  • Create a new task and give it a meaningful name, i.e. “LaunchAllApps”. Check run with highest privileges
  • Under Triggers, create a new trigger, chose to be launched “At log on”, select your specific user account and hit OK
  • Under Actions, add a new action to start a program, and then copy and paste the full command line you use for the StartApps shortcut earlier

Here are a couple of screenshots related to the steps above:



If you ever wanted to disable this task, edit its properties/Trigger and uncheck the Enabled.

6 Replies to “Station automation: starting and exiting multiple programs”

  1. When I execute the script, with 3 entries, I get a command screen that says “Done hit enter”
    Tried again with only one entry and got same screen.
    Tried on another machine with same results.
    Running win-7 enterprise. One machine has latest updates, the other older system with no updates.
    In both examples there are NO programs launched.

  2. Bob,
    couple things to try:

    – Make sure the shortcut’s target is correct. You can verify by running the exact command you typed in the shortcut’s Target box in a cmd window (old style batch commnand prompt). If you copy and paste the exact command, cmd.exe should run the PowerShell script correctly.

    – Make sure you have saved the text file with your applications

    – Make sure your applications have double quotes around the full file paths

    – Make sure the full file paths are actually correct

    Andy

  3. I made a test shortcut to launch Acrobat reader. When launching from command prompt using the contents of bob1.txt, the program launches correctly. when launching from the shortcut I get a box entitled: Administrator: StartAcrobat and it’s contents are: done. Hit Enter:

    StartAcrobat

    Shortcut target (set to run as administrator):

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass %userprofile%\documents\AppAutomation.ps1 -launchOrExit $true -applicationsFilePath %userprofile%\documents\bob1.txt

    bob1.txt contents:
    “C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe”

    Both files, bob1.txt and AppAutomation.ps1 are in My Documents.

    Bob

  4. I just ran the target info in cmd prompt with the same results. that is, the next line in cmd is: done. Hit Enter.
    hitting enter goes back to command prompt. There must be something wrong with my target entry. Please look at it for any error.
    Bob

  5. I just tried it with the exact script from this blog and this text file entries:

    “C:\WINDOWS\system32\notepad.exe”
    “C:\Windows\regedit.exe”
    “C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe”

    It worked. Here is another thought. If you are on a different OS, Powershell may not be the same version. I think that could cause issues. Please let me know what PowerShell version your script would be running and I can then try to make it work with that or fix the script so it is backward compatible… Can you do this for me:
    – open a PowerShell command prompt
    – type $PSVersionTable and post the output here.

  6. Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.

    PS C:\Users\Bob> $PSVersionTable

    Name Value
    —- —–
    CLRVersion 2.0.50727.8793
    BuildVersion 6.1.7601.17514
    PSVersion 2.0
    WSManStackVersion 2.0
    PSCompatibleVersions {1.0, 2.0}
    SerializationVersion 1.1.0.1
    PSRemotingProtocolVersion 2.1

    PS C:\Users\Bob>

Leave a Reply

Your email address will not be published. Required fields are marked *