Creating a .bat to load selected programs

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
oxnard
Posts: 4
Joined: 02 Aug 2012 23:37

Creating a .bat to load selected programs

#1 Post by oxnard » 02 Aug 2012 23:42

Hi there,

I've got such a simple problem that I can't seem to find any help for it. I hope you guys can assist.

In my job, we use a lot of different programs at once. I want to creat a .bat file to load all these programs in an order.
The programs are simple ones like Outlook and Lotus Notes, and some are word documents and excel spreadsheets. How can I do this?

I appreciate any help you can give me!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Creating a .bat to load selected programs

#2 Post by foxidrive » 03 Aug 2012 06:00

Code: Select all

@echo off
start "" "c:\folder1\program1.exe"
start "" "c:\folder2\program2.exe"
start "" "c:\folder3\file.xls"
start "" "c:\folder4\my book.doc"

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Creating a .bat to load selected programs

#3 Post by abc0502 » 03 Aug 2012 06:11

hi, here is the code:
@echo off
cls
Call :run "%programfiles%\Notepad++\notepad++.exe"
Call :run "notepad.exe"

Exit /B

:run
start "" %1
ping localhost -n 2 >nul
goto :eof

To add a program u write Call :run and the the program location,
It could be the full location like the red line or if it is recognized by the system like the notepad program you write it's name only

all your program should be written befor the EXIST /B
the green number is the time the batch wait between every program so you let the program to complete it's loading and the computer won't hang

oxnard
Posts: 4
Joined: 02 Aug 2012 23:37

Re: Creating a .bat to load selected programs

#4 Post by oxnard » 06 Aug 2012 17:20

Thanks Abc,

That method works well except when I add in the word document and the excel document.
As an alternative, I also tried

Code: Select all

START "" "N:\docs\etc\word.doc"



This didn't work either.
Not sure if this matters but both the word and excel docs are on a network drive.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Creating a .bat to load selected programs

#5 Post by foxidrive » 06 Aug 2012 17:25

Then you need to use this.


Code: Select all

start "" "\\server\share\file.doc"

oxnard
Posts: 4
Joined: 02 Aug 2012 23:37

Re: Creating a .bat to load selected programs

#6 Post by oxnard » 06 Aug 2012 17:57

Hi foxidrive,

I'm so close! I did as you suggested but they didn't open. So, to confirm that the server address was correct, I put in the path to the folders where the documents are kept. Sucess - they opened up. For some reason the document files don't open when I put that information in however.

Any suggestions? Appreciate your help!

EDIT: This is the error I get when I have the file address in the script:
"The process cannot access the file because it is being used by another process"

These docs are used by more then one person at a time, but in word and excel it should stil open and then prompt for read-only right?
Last edited by oxnard on 06 Aug 2012 18:20, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Creating a .bat to load selected programs

#7 Post by foxidrive » 06 Aug 2012 18:18

If your server is mapped to a drive letter then this *will* work


START "" "N:\docs\etc\word.doc"

Just double check the path/drive and filename.

Also, use the same command but use a drive path and filename on your local machine, to ensure that DOC is a registered filetype. It should open your default .doc viewer with the file loaded.

oxnard
Posts: 4
Joined: 02 Aug 2012 23:37

Re: Creating a .bat to load selected programs

#8 Post by oxnard » 06 Aug 2012 18:48

Thanks foxidrive!

Got it to work - realised in my case, my word file and excel file need to set to open as read only, and req a password for read/write.

A huge thanks again!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Creating a .bat to load selected programs

#9 Post by foxidrive » 06 Aug 2012 18:53

You solved it, well done.

Post Reply