Computer Hope

Software => Computer programming => Topic started by: Ryder17z on June 04, 2008, 01:14:05 AM

Title: Batch file with errors
Post by: Ryder17z on June 04, 2008, 01:14:05 AM
I have created a batch file that should do this :

1. I start ARstart.bat
2. ARstart gives a command to QRes.exe
3. QRes changes resolution
4. Miljard_r.lnk launches (A shortcut)
-----------------------------------------------
5. I end the game
6. ARstart.bat gives another command to Qres.exe
7. Qres resets the resolution
8. ARstart closes

Here is my code :

   
Code: [Select]
:@echo off
    echo Miljard?r is Loading...
    ::This make the game launch in the right resolution
    QRes.exe /x:800 /y:600
    Miljard_r.lnk
    ::This resets the resolution
    QRes.exe /x:1280 /y:1024
    Echo Miljard?r Closes...

The problems with code is :

1. Miljard_r.lnk starts before Qres have changed resolution - resulting in a fake statement - Qres thinks he is done, but he haven't done anything
2. The icons on my desktop moves like crazy - Is there anyway to lock each one at a specified point ?
3. How do I replace the questionmark in my code with the ASCII-letter "132"  ?

Does anyone know how to deal with it ?
Title: Re: Batch file with errors
Post by: Sidewinder on June 04, 2008, 08:42:24 AM
Quote
1. Miljard_r.lnk starts before Qres have changed resolution resulting in a fake statement - Qres thinks he is done, but he haven't done anything

If you run Qres from the command prompt does it work? How long does it take? Try adding a ping command after Qres to delay the start of Miljard_r.lnk

Quote
2. The icons on my desktop moves like crazy - Is there anyway to lock each one at a specified point ?

I would imagine so if you're changing the screen resolution. After you revert back to 1280x1024 are the icons in the proper locations?

Quote
3. How do I replace the questionmark in my code with the ASCII-letter "132"  ?

Use the Windows Character Map to find character 132 for your font. You can copy the character to the clipboard and paste it into your batch file.

Good luck. 8)

Title: Re: Batch file with errors
Post by: Ryder17z on June 04, 2008, 02:15:47 PM
1. Less than a second - when it works

2. Nope, that's why I need to lock them, otherwise my desktop gets very messy

3. Nope, it would only show the wrong letter

EDIT:

I have added this to my code :

SLEEP.EXE 1
Title: Re: Batch file with errors
Post by: blastman on June 04, 2008, 02:42:31 PM
I'd of done this;

Code: [Select]
@echo off

echo
echo Miljard?r is Loading..

::This make the game launch in the right resolution

start /wait QRes.exe /x:800 /y:600

start /wait Miljard_r.lnk

::This resets the resolution

start /wait QRes.exe /x:1280 /y:1024

Echo Miljard?r Closes...

Notice the 'start /wait' before running QRes and the Miljard link. It will make the batch file pause until the command/program has completed.

That should fix the problem with it loading the game before the res has had a chance to set.

As for the icons not being in the same place everytime, all I can suggest is using 'auto arrange' on your desktop.

hope it helps.
Title: Re: Batch file with errors
Post by: Sidewinder on June 04, 2008, 03:50:02 PM
You had the right idea with sleep. Ping can do the same thing but not everybody has the sleep command on their system. Using start with the /wait switch merely shifts the problem to another window.

Quote
1. Less than a second - when it works

Why and when doesn't it work? Perhaps you can test the return code. If you do check the return code, don't use the sleep command.

Code: [Select]
:@echo off
    echo Miljard?r is Loading...
    ::This make the game launch in the right resolution
    QRes.exe /x:800 /y:600
    if errorlevel 1 goto :eof
    Miljard_r.lnk
    ::This resets the resolution
    QRes.exe /x:1280 /y:1024
    Echo Miljard?r Closes...

For the icons, the previous post might be onto something. Set the desktop to auto-arrange the icons.

According to the standard ASCII chart, character 132 is character: ä. Why could you not get this off the Windows Character Map.

 8)
Title: Re: Batch file with errors
Post by: Ryder17z on June 04, 2008, 04:01:03 PM
/wait wont work

And that about that letter "ä" - It won't show up as it should, why does it give me an "ò" instead ?

When I launch the code now - the game has "almost" right resolution, but it's in the top-left corner with a grey box filling out the rest
 
The game is now launching in 1024x768 - But my desktop resolution is still 1280x1024 :-\

Here is the rewritten code :

Code: [Select]
@echo off
    echo Miljard?r is Loading...
    QRes.exe /x:1024 /y:768
    Sleep.exe 1
    Miljard_r.lnk
    Sleep.exe 1
    QRes.exe /x:1280 /y:1024
    Echo Miljard?r Closes...

I changed from 800x600 to 1024x768 due messy grapics when using 800x600

Seems hard to deal with this program :(

By the way :

I'm using the SLEEP.EXE dos file from here. (http://www.computerhope.com/dutil.htm)

I need to lock my icons - otherwise DreamScene will have icons on it ???
Title: Re: Batch file with errors
Post by: Sidewinder on June 04, 2008, 05:05:32 PM
Quote
The game is now launching in 1024x768 - But my desktop resolution is still 1280x1024

Not really understanding this, but hey, if the game is happy, so am I.

Did you try auto-arranging the icons? Right click the Desktop==>Arrange Icons By==>Auto Arrange.

The sleep command you have is fine. Just pointing out that sleep came with the Windows 2003 toolkit and not everybody has it installed.

Have you considered using DOSBox (http://www.softpedia.com/get/Programming/Other-Programming-Files/DOSBox.shtml). I've never used it but I understand it can help with old games.

Good luck. 8)

I have no answer for character 132 (ä). If you can't copy/paste it from the post, then whatever application you're using is interpreting it as something else. Could be your font.
Title: Re: Batch file with errors
Post by: Ryder17z on June 05, 2008, 04:07:27 AM
This game was created 2005 or 2006 - So it's not old

And I'm getting nowhere with this :-\

I just messed the whole game up now :(

/me leaves this project...
/me begins a new project...