Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
After searching these forums for anything similar to my situation, I post this. In my .bat file, i want to run a .exe with variables applied to the said program.. such as: .exe +set variable1 +variable2. The line I placed in my compile.bat file will boot just the program and will open to its main screen. To give you some history to hopefully answer some questions before they are asked: The program im intending to run is a game, Im an amature game designer and my compilation program runs in .bat. When the compilation program is completed I want my .bat file to call the game.exe and run the completed level. I would like to have it run similar to clicking on a Shortcut and having the shortcut run with variables after the .exe (or using the RUN command for that matter).
One other thing, related to above: Is there a similar command to 'If Exist' in winXP pro? im trying to hault the compile if it detects a .lin file.Thank you for your time
M_Hg

Don't you just want a command to lauch the exe? Use Start. You can use Find in WinXP instead of if exist.

Yes I do indeed wish to run the .exe but there is a bit more then that. This is the line ripped from the shortcut linked from my desktop:
C:\Quake3\quake3.exe +sv_pure 0 +devmap mymap
when i use the Start command, it will indeed start up the .exe file.. but thats where it ends. I am hoping that I can somehow tell it to continue reading the instructions of that line and not stop after the exe. I have tried enclosing everything in quotes, i have tried using:
Set game_options= +sv_pure 0 +devmap mymap
then completing it by using %game_options% to no avail.
Lode, you also mention a 'Find'.. are you meaning from the Start menu > Find files/programs? or is it actually a .bat command?
Thank you for your time
M_Hg

Well, if I understand correctly, Start is simply the command to open any file, but it won't read .exe files. Although bat files can be made to read simple text from a file. If you go into cmd.exe and type start/? it prints the full command syntax. It goes like:
START /wait /max /minimised /restored file.ext [parameters]
Find is another Dos command, but, I tested if exist in XP and it worked fine. So you should check that one again.

Ok.. i did manage to get the 'If Exist' command to work, the reason it wasnt working was because I did not have the full path to the file. Once i wrote the full path, it worked great.
Now i did invoke the start/? prompt to see exactly what I could do which only creates new questions: I noticed that there is a [/Dpath], im going to assume that this is the path to the .exe file, after that there are some priority classes then it gets to the interesting part. It mentions something about [command/program] & [parameters]. Now if i get this correct, the parameters only apply to the command/program line. Now it doesnt say much about that particular line, except about the program running in either a windowed app or a console app... im just a bit confuzed about that deffinition, as i was under the impression that the Path at the beginning had the actual path to the .exe file.. so that needs some clarification. One other thing mentioned is something about enabeling command extentions. Would this be the holy grail that im searching for that would allow me to seemingly run those additional variables and have it apply to the .exe?
Thank you for your time,
M_Hg

Sorry but I don't really know what the parameters could do. But I would assume they apply only within the dos environment and can only be redirected to plain text files with the > symbol. I think it also depends on the program you start, as to what the parameters can be.

I think that you want to START QUAKE witha user-specified map.
START will do this, - you DEFINITELY want the ?MAX parameter for full-screen execution.
The [command/program] bit is the
C:\Quake3\quake3.exe
part of your desired final Command,
& the [parameters] bit is the
+sv_pure 0 +devmap mymap
part.Quake3,exe is your PROGRAM, and +sv...mymap part is the PARAMETERS for thePROGRAM quake3.exe
To clarify the Path bit, C:\FOLDER\PROGRAM.exe is the fully qualified and non-ambiguous name of PROGRAM.exe - you may have other copies of PROGRAM.exe in other folders, and the Path DEFINES EXACTLY which PROGRAM.exe you want to run.
DOS/WIN have a sometimes useful habit of searching for PROGRAM.exe first of all in whatever folder the call is made, then sequentially along the PATHs defined in the PATH Environment Variable. This makes it easier for the user to just "START /r /w NOTEPAD.exe C:\MYSTUFF\JAN2003.TXT" without having to know exactly where NOTEPAD.exe has been put by the system.
the /r indicates to start NOTEPAD.exe in a "normal" restored window, the /w says "wait until NOTEPAD IS CLOSED BEFORE PROCEEDING".
This allows you to (for example) edit/write JAN2003.TXT and then copy it to D:\NEWSTUFF\JAN2003.TXT by using a BAT file with the following command sequence:1) START /r /w NOTEPAD.exe C:\MYSTUFF\JAN2003.TXT
2) COPY C:\MYSTUFF\JAN2003.TXT D:\NEWSTUFF\JAN2003.TXTBecause the /w in the START command will make the BAT file Wait until NOTEPAD is closed before attempting the COPY.
Yes, you could create a compile-test-edit-loopback_to_compile BATchfile by using this technique, but you'd have to include a CHOICE command to allow you to get out of the loop.
Baldy.

@echo off
set bsp_var= -meta -threads 1 -leaktest
set vis_var= -vis -saveprt
set light_var= -light -filter -thresh 0.2 -super 2 -samples 2
REM Dont forget to change the 'if exist' line if you change your q_path or q_game setting
set q_path=c:/Quake3
set q_game=c:/Quake3/quake3.exe
set map_dir=c:/Quake3/baseq3/maps
set map_path=c:/Quake3/baseq3/maps/%1.map
set q3map_path=c:/Quake3/q3map2_256/q3map2.exe
set gen_options= -fs_basepath %q_path% -vREM run the Bsp process
%q3map_path% %bsp_var% %gen_options% %map_path%
IF EXIST %map_dir%/%1.LIN GOTO EndREM run Vis process
%q3map_path% %vis_var% %gen_options% %map_path%REM run light process
%q3map_path% %light_var% %gen_options% %map_path%
pause
Exit
:End
pause
Ok, thats my .bat file... now what Brian said would apply such this:START %q_game% +sv_pure 0 +devmap %1.bsp
I tried that, and it didnt work.. then i created a seperate .bat file to just test loading Quake.
I ran a few different variations of the following .bat file just to see if I could figure out the combination that works. Im not about to give up on something that should be simple:
@echo off
set q_game=c:/Quake3/quake3.exe
set map_location=c:/Quake3/baseq3/maps/%1.bsp
set game_variables= +sv_pure 0 +devmap %map_location%
set start_quake= %q_game% %game_variables%
start %start_quake%
ExitI tried to define the variables inside a seperate SET command, i tried running the variables after the START command. They all just opened up Quake3 to the main menu. Which im telling it to do, but i want more to happen. I was then thinking if shortcut files have an extention, I could call a shortcut that has all that information in it. The shortcut works and will start up my map inside the game. I was hoping for a similar feature inside DOS. It might be a possibility that it isnt possible to this extent.
For the record, do shortcut files have an extention?
M_Hg

Ok.. i figured out a work around. As I thought more about how to incorperate a shortcut into my .bat file.. I just copied the shortcut that i had on my desktop, stuck it in C:/ and then used the START command to run the shortcut and it worked. Now if there isnt a better way of doing this, this way of doing it will have to suffice.
M_Hg

Yes indeedy!
A shortcut to a WINDOWS Application is a .LNK
A shortcut to a DOS Application is a .PIF
A shortcut to a WebSite is a .URLGlad to see that you've worked a solution, but keep in mind that a BATch file CANNOT do any more than YOU can, from the command line! So, if you can MANUALLY start QUAKE with the required parameters, and have it proceed as desired, then your BATch file must imitate EXACTLY whatever you have done MANUALLY.
But if it wont do it manually, a BATch file doesn't stand a chance!
The only caveats are that some special characters (Pipes etc) cause havoc inside BATch files, and System Environment Variables are a whole other story. They depend highly upon the OS, and have a limit to their total size.Upon examining Response 7 above, you'll see that ONLY the BATch file with ALL of those bits&pieces will run q3map2.exe a total of THREE times, with differing parameters, in order to set up whatever IT has been designed to do.
It runs the Bsp Process, then the Vis Process, before running the light Process.
C:\Quake3\quake3.exe +sv_pure 0 +devmap mymap
In this commandline, Program=quake3.exe %1=+sv_pure %2=0 %3=+devmap %4=mymap
If the BATch file listed is called with the parameters above, and you go through performing all substitutions which DOS will do on the fly, you'll get the block down below.
When DOS reads (Parses) a BATchfile, and it hits a % sign it realises that this %blah% is a shortcut of types, and it looks up its list of environment variables to find blah= ... then it REPLACES the term %blah% with the entry from its table. This may or may not include further % terms, and DOS just merrily expands ALL the terms and obeys the FINAL instruction.
@echo off
set bsp_var= -meta -threads 1 -leaktest
set vis_var= -vis -saveprt
set light_var= -light -filter -thresh 0.2 -super 2 -samples 2
REM Dont forget to change the 'if exist' line if you change your q_path or q_game setting
set q_path=c:/Quake3
set q_game=c:/Quake3/quake3.exe
set map_dir=c:/Quake3/baseq3/maps
set map_path=c:/Quake3/baseq3/maps/%1.map
set q3map_path=c:/Quake3/q3map2_256/q3map2.exe
set gen_options= -fs_basepath %q_path% -vHere I have manually replaced each %term% with its values as set above:
REM run the Bsp process
c:/Quake3/q3map2_256/q3map2.exe -meta -threads 1 -leaktest -fs_basepath c:/Quake3 -v c:/Quake3/baseq3/maps/+sv_pure.map
IF EXIST c:/Quake3/baseq3/maps/+sv_pure.LIN GOTO EndREM run Vis process
c:/Quake3/q3map2_256/q3map2.exe -vis -saveprt -fs_basepath c:/Quake3 -v c:/Quake3/baseq3/maps/+sv_pure.mapREM run light process
c:/Quake3/q3map2_256/q3map2.exe -light -filter -thresh 0.2 -super 2 -samples 2 -fs_basepath c:/Quake3 -v c:/Quake3/baseq3/maps/+sv_pure.map
pause
Exit
:End
pause
Possibly you can see now what is actually going on. ... The BATch file is really quite complex, and has several terms repeated in many places. To ensure that any alteration is reflected in each instance, data has been assigned to Environment Variables (Evars) - now this CAN fall down, particularly under Windows, where you have little control on how much Evar space is reserved.
Sometimes Evars just "don't take" - and that is because they've overfilled the available space, and DOS can't put error messages on a Graphics screen!
Anyway, with the expanded version above, maybe you can see what is actually happening, and how to make it go the way you want.Baldy.

Ok.. my understanding of the %1 command was that anything after a shortcut (the shortcut linking to the .bat file), [this is located on my desktop] IE: 'C:\Quake3\q3compile.bat'
That is my target for my shortcut. Now what i have done was add the name of my map 'MY_UBER_MAP' after that command line inside the shortcut, so now it looks like this: C:\Quake3\q3compile.bat MY_UBER_MAP.
Now anytime that the .bat file comes across a %1, it replaces that command/variable with 'MY_UBER_MAP'.
Doing it this was is easier for me because Im working on multiple levels but using one .bat file to compile them all. So changing one line inside a shortcut file is easier then tracking down my .bat and opening it up w/ a .txt editor and changing the appropriate line w/ the new information.
Now on to the more important thing: This is what i gather from reading your post and comparing it to my statement above. If I append +sv_pure, 0, & +devmap respectively they would be assigned the variables %2, %3, & %4 (i dont need to restate the level name as thats assigned to %1).
Then I could create a line similar to:
START %q_game% %2 %3 %4 %1.bsp ---> looks like this w/o shortcutting:
START c:/Quake3/quake3.exe +sv_pure 0 +devmap MY_UBER_MAP.bspTo get the above information correct, I would have to add after my shortcut, change it to: 'C:\Quake3\q3compile.bat MY_UBER_MAP +sv_pure 0 +devmap'
Are my assumptions correct?
If I am correct, then I sould be able to set those variables from inside the .bat file.
(forgive me if my train of though stumbles, im tired and must sleep)
M_Hg

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |