Batch Files

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

eddie5659

Thread Starter
Moderator
Malware Specialist
Joined
Mar 19, 2001
Messages
37,298
Hiya

How do you actually create them? I assume these can be used to start a series of programs when activiated.

We use NT at work, but soon moving to 2000, when they can upgrade all the PC's on site.

Anyway, when I log on, I usually open Outlook, BPCS (internal database), QSIS (global database), and a Web page.

How would I go about creating a batch file? The IT dept let you do most things, but if you can't, its because they disable it.

For instance, someone changed the file extensions, and it let them. Never did find the culprit :mad:

Thanks in advance

eddie
 
Joined
Aug 17, 2001
Messages
7,486
Open Notepad. Write a series of Dos commands. Onr command per line. Save the file as name.bat


Voila. A Batch file.
 
Joined
Jun 26, 2000
Messages
7,762
for example,I have a batch file in my Startup folder for Win98SE which contains the following:

@echo off
net use y: \\randy-350\c
net use z: \\randy-350\d
DELTREE /Y C:\WINDOWS\TEMP\*.* > NUL
rem C:\Windows\DrWatson.exe
exit


This reestablishes my networked drives, deletes my Temp folder,and used to run Dr Watson before I REMmed it out, then closes the dos window.

Batch files are cool and easy to automate tasks that happen often.
 

eddie5659

Thread Starter
Moderator
Malware Specialist
Joined
Mar 19, 2001
Messages
37,298
Thanks guys

Right, say for instance all I'm wanting to do is open a few programs, so that I can wander away, and grab a cuppa (they're slooow pc's)

Randy, you said that you ran Dr Watson, so you just put C:\Windows\DrWatson.exe

I assume I track down the actual locations, on the C drive, as others relate to Public, Private, etc.

Do I need that '@echo off' bit in?

I'll have a look at the locations tomorrow at work.

Thanks

eddie
 
Joined
Jun 26, 2000
Messages
7,762
No, the echo off bit just means you don't see the commands as they are executing, and the close means the window closes on exit.


doing a batch file is as easy as that, just find the full location of the executable and put it in there.
 

eddie5659

Thread Starter
Moderator
Malware Specialist
Joined
Mar 19, 2001
Messages
37,298
Great, I'll have a go tomorrow. I'll let you know if I crash the network :D

eddie
 
Joined
Jun 20, 2002
Messages
1,716
Here's a batch I use to start 3 programs in w2k:

@ECHO Off
Start D:\Programs\PopupKiller\PopupKiller
Start D:\Programs\PrintKey\Printkey
Start D:\Programs\Opera\Opera
 
Joined
Jul 7, 2002
Messages
6,427
Hi Eddie,
Not an expert with batch files...:rolleyes: but I thought I could post this useful link for you -
Batch Files

HTH!

(PS : Tell me if the link is 'really' useful :p)
 

eddie5659

Thread Starter
Moderator
Malware Specialist
Joined
Mar 19, 2001
Messages
37,298
Thanks pvc, haven't looked at it fully, as I'm ahem, working :p

Okay, I can get Outlook to open:

@echo off
start C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE

But QSIS is pretty hard. Does DOS recognise underscore _ ?

The location is:

C:\Program Files\QSIS_NG\QSISNG.EXE

Blast, can't get Outlook to open now. Gonna try over the week, so I'll let you know. Each program has about 10 locations :(

eddie
 
Joined
Aug 17, 2001
Messages
7,486
Eddie,

In Win98 you can use Quotation marks around the full path to a file and the path is read. I am not sure you can do that in NT4.


Otherwise, use the short file names. The spaces in the name ends the path if your system cannot read long file names. And there is a limit to the number of characters you can use. A quick way to get the path is to open a command prompt. Open the Folder which has the file you want to open. Go to start>Run and type command (or cmd) I am not sure for NT. The full path to that folder will show in the Dos Box.

When creating the Batch, type the path to the exe. I don't think you need Start. If you wanted to open a text file, you would need Start. But not for an exe.




@echo off is a command which prevents the Dos box from showing the commands as they are executed.

C:\Program Files\QSIS_NG\QSISNG.EXE should not be a problem if you use the correct name format to open it.




Also, create a shortcut to the program and have it run minimized and close on exit. To do that right click on the batch and choose properties. Click the Program Tab. Choose Run Minimized and check the Close on exit box. This will create a shortcut icon in the same folder as the batch. You can then move the shortcut to a convenient location. You can change the icon too if you like.

See if this helps.

Mo
 

eddie5659

Thread Starter
Moderator
Malware Specialist
Joined
Mar 19, 2001
Messages
37,298
Thanks Mo, I'll try it in the morning.

I'll do it throughout the day, but as I say, there are about 10 different locations for each one I want, so may be a case of replying in a week :)

I'll keep you all informed.

Thanks

eddie
 
Joined
Jun 20, 2002
Messages
1,716
Mosaic1, in w2k I'm unable to get a batch file of this type to work without the "start" at the beginning.

eddie5659, with C:\Program Files\QSIS_NG\QSISNG.EXE, you might try changing the name of the folder QSIS_NG to QSISNG. That's what I had to do with Popup Killer. I had to get rid of the space for it to work. I did it with the folder and the exe file.
 
Joined
Aug 17, 2001
Messages
7,486
DVOM,

That's a good point to know about Start on Win2k. I'll have to try it on XP and see if it is the same. The space is the problem for DOS. If you use the short file name it should work. I doubt Eddie can rename folders and files used by others.
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,429
You don't need START proceeding the program name in the batch file for any version of windows. START is used to invoke a separate instance of the command processor, so if you have a batch file:

START dir
START dir
START dir

You'll end up with three command prompt windows open, all with a directory listing in them. This is probably not what most folks want to do. :)

START is useful if you have several long running processes that you want to run concurrently.

For more information about START, try typing:

START /?

... at a command prompt.
 
Joined
Aug 17, 2001
Messages
7,486
There must be a difference between cmd.exe and command.com

I just ran a simple batch file in XP. I found I did need to use Start in front of each item or the first item ran, but the second didn't until I closed the first. Without the start in front of the item, the next command does not execute until the first has finished. That means I had to close the program I opened before the next line would execute. If you want to open more than one program at a time, use start in NT.


In 98, if I try to run a text file without using Start, I get a bad command error. What I said originally does apply to Win98SE using Command.com. I can list several programs not using start and they all open not waiting for the prior to close. Not so in XP.

I see this is just one more difference between NT and Win9x.
The rule of thumb should be test it and see how it goes on your OS.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top