Starting multiple programs in MS Windows

While not Excel specific, I thought this would be useful to others.

There are instances when I want to run a set of programs. One example is shortly after I log on to my computer when would like to start up MS Outlook, Firefox, IE 64bit, and Forte Agent.

I wrote a VBS script, run through the Windows Script Host, that does the needful.

Create a text file (use Notepad if you want or MS Word)

Set WshShell = WScript.CreateObject(“WScript.Shell”)
WshShell.Run “”“%ProgramFiles(x86)%Microsoft Sysinternalsprocexp.exe”“”
WshShell.Run “”“%ProgramFiles(x86)%mozilla firefoxfirefox.exe”“”
WshShell.Run “”“%programfiles%internet exploreriexplore.exe”“”
WshShell.Run “”“%ProgramFiles(x86)%microsoft officeoffice12outlook.exe”“”
WshShell.Run “”“%ProgramFiles(x86)%Agentagent.exe”” c:users mForteAgent”

Save the file as “My Programs.vbs” or whatever you prefer. This is one of those rare instances when I would consider putting a file on the desktop. To run all the programs double click the file. Assuming you have the correct full program name in each line, that program will start running. An error on one line will terminate the script.

Note the required use of quotes around a program name when the name has a space in it. To insert a quote in a string one must use two consecutive quotes. Consequently, a quote at the start of a string requires three quotes in succession. The first starts the string and the next 2 cause the 1st character in the string to be a quote. Similar logic applies when the quote is at the end of the string. Otherwise, one would see just 2 consecutive quotes as after the .exe in the last line of the file.

The above uses the environment variables programfiles and ProgramFiles(x86), which map to the 64bit program directory and the 32bit program directory respectively. To not use them, replace the %variable% with the explicit path.

Set WshShell = WScript.CreateObject(“WScript.Shell”)
WshShell.Run “”“C:Program Files (x86)Microsoft Sysinternalsprocexp.exe”“”
WshShell.Run “”“c:program files (x86)mozilla firefoxfirefox.exe”“”
WshShell.Run “”“c:program filesinternet exploreriexplore.exe”“”
WshShell.Run “”“c:program files (x86)microsoft officeoffice12outlook.exe”“”
WshShell.Run “”“C:Program Files (x86)Agentagent.exe”” c:users mForteAgent”

Tushar Mehta

Posted in Uncategorized

25 thoughts on “Starting multiple programs in MS Windows

  1. Curious as to why you would run the SysInternals procexp.exe file at startup?
    Are you doing a visual scan for non-native (viral) processes?

  2. Why wouldn’t you just drag an appropriate shortcut for each program into the Startup directory ?

  3. Jim: I run procexp at startup as a replacement for Task Manager – it provides more info on specific processes than TM, and I find it more responsive at high CPU loads.

    Hui: my guess is that sometimes you don’t want everything to start up as you log on – especially if you want to get to something else quickly after logging on. For me, waiting for outlook to boot up at log on in a killer. Though one suggestion would be to include the script in the startup folder, but add a ‘wait’ command at the start of the file in order to delay the start up of these programs.

  4. Rick hit the nail on the head on both issues.

    Procexp might provide me with a visual indicator if something is wrong but I don’t know for sure. I prefer it to task manager.since the overhead of having it running is minimal…

    I also don’t want my “web-facing” programs starting at computer startup. There are times I want to do something else first.

    Use of a VBS script *after* start up is only *one* example where it is usable. Focusing the discussion exclusively on startup misses the broader possibilities.

    I use the script when *I* am ready to run web-facing programs. I also use the script if at some point I have terminated those programs and want to re-initiate them.

  5. Inflexible.

    Plus VBScript is a problem, er, solution in search of a problem.

    Batch files/shell scripts are far more flexible. For example,

    @REM sample batch executor
    @setlocal enableextensions
    @echo off
    if “%~1” == “” (echo usage: %0 directory & goto :EOF)
    if not exist “%~1.” (echo %0: error: directory “%~1” doesn‘t exist & goto :EOF)
    cd /d “%~1”
    for %%f in (*.*) do start “” “%%f”

    Add possibly many different shortcuts calling this batch file.

    The batch file needs to be called with a drive/directory path as an argument. It then starts all files in that directory. In short, this functions like the Startup folder at login.

    If you can’t bear to waste any disk space and are using NTFS drives, use an equivalent for the POSIX ln command (GNUWin’s works reasonably well) to create hard links rather than shortcuts.

  6. Some great info here, guys!

    I do already use batch files to start groups of IE windows for specific tasks on my work PC (corporate IT are yet to arrive in 2009 so IE6 is my only option).

    However, I can also see the possibility of using this concept to start groups of applications used for specific tasks (say audio editing, or stock trading).

    A couple of questions though;
    – is it possible/advisable to use any of these methods to stop processes that may conflict with a task-specific application?
    – is there a way of starting Excel with specific Add-ins enabled?

    Thanks for all the great tips, people! Seriously, this has got to be the most useful blog I’ve found anywhere – it gets checked every day!

  7. I haven’t checked the VBScript options but in batch files you can use:

    START “1? /min “C:Whatever hingy.exe”

    To launch a program in a minimised state.

  8. There are several ways to load XLA add-ins. You can even include them in the Excel command line. For XLLs, I think editing the registry is the only way.

    @Dennis: what would the equivalent PowerShell script look like? To be honest, my impression of PowerShell is that it’s gross overkill unless you want to manipulate output from programs.

  9. Let me see if I got this right.

    I can use the “solution looking for a problem” script in which case I have one file that is trivial to understand and maintain.

    And, one double click is all I need to use it.


    I can create a folder and add shortcuts to the programs I want to run.

    Then, I can modify those shortcuts that need a custom “start in” specification.

    Then, I create a batch file using a language that I doubt most people are familiar with.

    Then, to use this “solution” I have a choice.

    Create another file that will run the batch file with the folder name as an argument. And, I get to double-click this file.


    Use some number of clicks to open a command window and then type in the *full* pathname to the batch file and the *full* path name to the folder.

    Did I miss something?

  10. Or you could just use a batch file to runs the programs. The only additional syntax beyond what you’d enter in Windows’s Run dialog or Create Shortcut dialog would be to start each line with ‘@start “” ‘. Trivial and much simpler than instantiating an WSHShell object and making pointless .Run method calls.

    @start “” “%ProgramFiles(x86)%Microsoft Sysinternalsprocexp.exe”
    @start “%ProgramFiles(x86)%mozilla firefoxfirefox.exe”
    @start “%programfiles%internet exploreriexplore.exe”
    @start “%ProgramFiles(x86)%microsoft officeoffice12outlook.exe”
    @start “%ProgramFiles(x86)%Agentagent.exe” c:users mForteAgent

    Making a virtue of brute force!? Next you’ll be telling us you can walk and chew gum asynchronously.

  11. Figures I’d forget to add the “” after @start in the 2nd and subsequent lines.

    Point is still that batch files are much simpler than VBScript for just launching batches of programs and/or opening batches of files in their associated applications. Maybe batch files are hopelessly 1980s, but VBScript is hopelessly 1990s. Current technology is PowerShell. Still, batch files are simplest AND most understandable.

  12. To load specific addins when running Excel through VBS is straightforward:

    sub loadAnAddIn(XL,addInName)
        end sub

    Dim XL ‘As Excel.Application
    Set XL = createobject(“Excel.application”)
    XL.Visible = True
    xl.workbooks.add() ‘not really needed but why not? {grin}
    loadAnAddIn XL, “tm chart utilities (ribbon ui)”
    loadAnAddIn XL, “tm create addin (ribbon ui)”

  13. Potential problem with Tushar’s approach: any add-ins installed in the script remain marked as installed in the registry, which means Excel will load then on subsequent regular launches until they’re uninstalled either manually or by script.

    Better just to open XLA add-ins like standard workbooks. With macros enabled, those XLAs will work like usual as add-ins, but they won’t be recorded as installed add-ins in the registry. If the desired XLAs have already been marked as trusted, it’s possible to load Excel with just such add-ins via the batch command

    @start “” excel.exe “..add-in_1_path..” “..add-in_2_path..” “..add-in_3_path..” … /safe

    Yes, this is an abuse of Safe mode, but it works with a single command line.

    As for XLL add-ins, there’s no clean, general way to handle them without using a workbook with an Open event handler which records initially installed add-ins while it unloads all but already-installed desired add-ins and then installs add-ins not already installed, and a Close event handler which uninstalls all session-only add-ins and reinstalls add-ins which were uninstalled by the Open event handler.

    Managing persistence takes some experience. Best not to rush out more VBScript code without pondering its full implications.

  14. fzz: Opening an addin rather than loading it has problems of its own. Properly written addins may not take kindly to being opened.

    I don’t know what it is about me that seems to guarantee some form of criticism from you. You come across as willing to go to the ends of the world and beyond to find a flaw – pathological more likely than not – in whatever I post.

    Here’s something for you to point out as being “brute force” “inflexible” and “inexperienced”

    Tushar says: In everyday activities, for regular folks, 1 + 1 = 2.

    And, you know what’s really great?

    I guarantee that anything you post from now on will solicit either no response from me or just one: A link to this message.

  15. VBScript is generally unnecessary. It serves a purpose in web pages. There are better tools for local scripting.

    Then the clever rhetorical flourish about future responses. Almost as clever as the original article.

    You wanted to show how clever you are, and even more you wanted others to acknowledge your cleverness. Objectionable.

    Nice point about simple arithmetic, but batch files are 1 + 1 = 2. VBScript is .1 + .2 – .3 + .4 + .5 – .6 … = 2. You’re trying to claim the former for yourself when the latter is the case.

    Link to whatever you want.

  16. Oops, blue on blue.

    I’ll use batch files and VBScript and whatever else I can to get me what I want. Batch files are still very current (O.k. so we had to wait until Windows 2003 for a TAIL command like in Unix) but I regularly use them. Yes they have some quirks, but for really quick and dirty solutions to routine problems it’s worth the effort.

    There’s only one book worth a damn on the subject: Windows NT Shell Scripting by Tim Hill.

  17. fzz,

    Because Powershell use the .NET Framework and its objects it requires CLR to run which cause an overhead. It target IT-administrator and developers. I have started out to learn it (both the command utility and the script language) so I prefer, at present, to point to a web placed which shows one script example related to Excel:

    I do not necessarily agree that it would be an overkill within this context. Creating a script that automate different tasks is one of its main field and therefore qualify to be mentioned and discussed here. At least, that’s my opinion.

    The key point with PowerShell is that it fully support the security paradigm on the .NET platform. For instance, it means that we cannot double click on a script file to run it in the explorer . It’s also possible to read/write Windows Registry as well as check if files have been digital signed or not.

    I intend to publish some of my findings on my blog (which is a dedicated .NET blog).


    Yep, one thing that comes to my mind is:

    *********** Diversity **********

    PowerShell is a well known technology and Your comment only shows Your lack of knowledge and ignorance. It’s available for Windows XP, Vista and Windows 7 and it’s the natural successor of all good old technologies.

    Kind regards,

  18. Ha, ha, ha. That’s funny, Dennis.

    …it requires CLR to run which cause an overhead. It target IT-administrator and developers…

    …For instance, it means that we cannot double click on a script file to run it in the explorer…

    Thanks. You just made my day.

  19. fzz, quite right, but it’s so much easier to TAIL -F a log file than produce a batch file to simulate the same result. At the risk of going off topic I’d be interested in your version though

    I should mention for interested readers that tail.exe is part of the Windows 2003 Resource Kit so you may have to speak to your server guys to get hold of it.

    #NOTE: The term ‘guys’ in relation to Windows server management is not gender specific. The name derives from their ability to tie a network down so hard you can barely get any work done. Like a ‘guy’ rope on a tent in a hurricane. See? ;)

  20. fzz:
    Quote: .1 + .2 – .3 + .4 + .5 – .6 … = 2.

    Just to sidestep the above debate, I was thinking of this infinite sum, and can’t see that it converges, particularly not to 2.

    = (.1 + .2 – .3) + (.4 + .5 – .6) + (.7 + .8 – .9) + (1.0 + 1.1 – 1.2) + …
    = 0 + 0.3 + 0.6 + 0.9 + …
    => infinity?

    Also I can’t figure out what the aeries you intended was. I’m always a sucker for interesting number patterns – what was the series you intended?


  21. Hi all,

    A belated thanks for your responses to my query, and apologies for the delay in my reply.

    I appreciate the advice you all offered, however, in my work environment, I can’t test or implement any solutions involving registry editing (or indeed anything requiring windows admin privileges). Which presents a significant challenge to you all in suggesting viable solutions… but not half the challenge I face on a daily basis trying to get anything done with one hand tied behind my back. ;) The nature of consultancy in a particularly paranoid corner of the defence industry though, I guess… (@gruff999 – definition of ‘guys’ is spot on, in this case).

    Also, sorry that my query seemed to spark some animosity – my intention was certainly not to put any cats among pigeons! :)

Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.