1.

Solve : Help with XP Startup Bat File?

Answer» FIRST POST, so go easy on me Guys
Sorry if this falls below the NORMAL standards.......but I am very new to this and need big help

This batch file:-

cd c:\PROGRAM files\Program 1 DIR
start /wait Program 1
cd C:\Program Files\Program 2 DIR
start Program 2
exit

Is to resided in my XP startup folder.
When windows boots it is suposed to run the first program......wait until it is completed.......then run the second program.

What it actually does is run the first program then halts, with the DOS box left open :-?
I've tried substituting Call for Start, but still can't get it to function correctly.

Can someone help

wizz
Quote
When windows boots it is suposed to run the first program......wait until it is completed.......then run the second program.
Code: [Select]cd /d "c:\program files\Program 1 DIR"
Program 1
cd /d "C:\Program Files\Program 2 DIR"
Program 2
exit

You can change both the drive and the directory with a cd command provided you use the /d switch. While start and call have their uses, you don't need them for simple program calls.

Hope this helps. 8-)

Welcome to the Forum

I don't see where the problem is ? The black scren still open means that it is waiting.

AlmnQuote
Quote
When windows boots it is suposed to run the first program......wait until it is completed.......then run the second program.
Code: [Select]cd /d "c:\program files\Program 1 DIR"
Program 1
cd /d "C:\Program Files\Program 2 DIR"
Program 2
exit

You can change both the drive and the directory with a cd command provided you use the /d switch. While start and call have their uses, you don't need them for simple program calls.

Hope this helps. 8-)


Thanks for the response.

Unfortunately this still does not work. Exactly the same thing happens...the first program ( a dot.net application ) executes then the script stops leaving the dos box open.
Only when I close the first program does the rest of the script run and complete.

Any idea what is happening :-?

Quote
Welcome to the Forum

I don't see where the problem is ? The black scren still open means that it is waiting.

Almn

That is the problem. I need it to run the second program after the first has executed.....but it doesn't. It just sits there waiting with the dos box open.

Wizz
It's like pulling teeth. Gonna guess this .net program either has an exit button or the user must click on the X in the upper right hand corner to end the program. The batch file is doing exactly what it's supposed to do. By introducing interactive programs into the mix, the batch file will wait until the user ends program 1 before cranking up program 2.

There is no error here; everything is operating as documented.

8-)

Quote
It's like pulling teeth. Gonna guess this .net program either has an exit button or the user must click on the X in the upper right hand corner to end the program. The batch file is doing exactly what it's supposed to do. By introducing interactive programs into the mix, the batch file will wait until the user ends program 1 before cranking up program 2.

There is no error here; everything is operating as documented.

8-)


So how do I get the second program to load as well :-? Both programs need to be running. HELP !Quote
When windows boots it is suposed to run the first program......wait until it is completed.......then run the second program.

Quote
So how do I get the second program to load as well Huh Both programs need to be running. HELP !

So which is it? You want both programs running at once? or do you want them to run sequentially?

To run both programs at once use the start command without the wait switch for both programs. Both programs will crank up, run in two separate windows, and most importantly run independently of each other.

No need to go over the sequential thing. You've already got that; end program 1 and program 2 cranks up.

8-)Sorry...I'm not trying to confuse you on purpose.

I need to have both programs running, BUT, the first program must be fully loaded before the second one loads.

I DO know the first program takes 11 seconds to load so perhaps there is a way a timer could be used ?

The reason I need this is because if the second program loads too soon the complete process is un-sucessful.

If I manually start the first program.......wait 11 seconds.....then manually start the second program all is well. All I am trying to do is automate this sequence via XP's startup folder.

Hope that explains my aim more precisely. Have you any ideas how I can achieve this ?

wizz


PS: Many thanks for your efforts, they are greatly appreciated
In that case I would simply write a VBScript and be done with it:

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\program files\Program 1 DIR\Program 1.exe"
WScript.Sleep 11000 ' 11 sec delay
WshShell.Run "c:\program files\Program 2 DIR\Program 2.exe"

Save script with vbs extension and run as wscript scriptname.vbs

Note: the time delay is in milliseconds. You can play around with the TIMING factor.

You could do this in batch also; WinXP does not ship with choice so unless you saved a copy from a previous edition of Windows, you'd use ping for the time delay. Ping is not as accurate as sleep.

8-)

With any luck, this will put this post to sleep. Quote
Sorry...I'm not trying to confuse you on purpose.

I need to have both programs running, BUT, the first program must be fully loaded before the second one loads.

I DO know the first program takes 11 seconds to load so perhaps there is a way a timer could be used ?

The reason I need this is because if the second program loads too soon the complete process is un-sucessful.

If I manually start the first program.......wait 11 seconds.....then manually start the second program all is well. All I am trying to do is automate this sequence via XP's startup folder.

Hope that explains my aim more precisely. Have you any ideas how I can achieve this ?

wizz


PS: Many thanks for your efforts, they are greatly appreciated



another way to do it is to separate the 2 programs into different batches.
you could schedule them more than 11secs apart to run.
After first program runs successfully, it will create a "done" file, just to indicate that it runs successfully.
your second batch will check for this "done" file, and start running the second program if its there.


Quote
In that case I would simply write a VBScript and be done with it:

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\program files\Program 1 DIR\Program 1.exe"
WScript.Sleep 11000 ' 11 sec delay
WshShell.Run "c:\program files\Program 2 DIR\Program 2.exe"

Save script with vbs extension and run as wscript scriptname.vbs

Note: the time delay is in milliseconds. You can play around with the timing factor.

You could do this in batch also; WinXP does not ship with choice so unless you saved a copy from a previous edition of Windows, you'd use ping for the time delay. Ping is not as accurate as sleep.

8-)

With any luck, this will put this post to sleep.

OK, Thanks.
How do I run the vbs file from XP startup. Do I just place it in there or do I need to do anything else.
Appologies again, but I did tell you I am a complete novice when it comes to scripting. So please bear with me.

wizz



PS: when I run this script from my desktop, I get this error

Script phoco.vbs
Line 2
Char 1
Error The system cannot find the file specified
Code 80070002
Source (NULL)




Either create a shortcut in the startup folder or if you want to test it from the Windows Run box, run it as wscript drive:\path\scriptname.vbs. The drive and path need to be actual values.

Open up the startup folder; RIGHT click an empty space within the folder==>New==>Shortcut. Fill in the values as requested. Note the actual program you are running in c:\widows\system32\wscript.exe
The fully qualified name of the script is passed along the command line to wscript. You can use %windir% as the startup directory.

Amazingly enough, you can write a vbscript to create the shortcut.

8-)






Discussion

No Comment Found