Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Does anyone have a suggestion/solution on running a batch file from within the login script (not at the end after an exit), but not having to manually close the spawned window?
For example, I create a batch file, test.bat, and call it from the middle of my login script. The test.bat file runs, but I am left with a DOS window with 'finished' at the top.
I can create a pif, modify it to close automatically, but that only seems to work on the machine I created the pif file from, although I have copied to a common area on the network. I launch the pif from another workstation, and I still have to close the window.

Try initially to set up a once-off copy command in the login script to copy the working pif file to the local workstation when the user logs in. When all users have logged in they should a have a copy of the pif file that should behave the same as the original one.
Might work.

This is how I used batch commands in a script. Though it has been a few years.
#command /c name.bat
Make sure this follows any DOS/WIN search
paths. The name.bat can have any prefix you prefer upto an 8 character word.............................................
or you can use the EXIT command at the end of their last login script.
EXIT "name.bat"
You are limited to an 7 character prefix name.
There are some great examples of some of these on novell's knowledgebase.

Launching the batch files are not a problem. I am attempting to figure out/understand how to close the spawned DOS window automatically.
To clarify, this is not an 'exit' batch file, rather one I wish to call in the middle of the script, and I have attempted to invoke an exit at the end of a batch file.
I use this line in my scripts to capture some user data.
no keys------
#COMMAND /C ECHO %LOGIN_NAME %P_STATION %DAY_OF_WEEK %MONTH_NAME %DAY,%YEAR %HOUR:%MINUTE %AM_PM %OS %OS_VERSION %NETWORK_ADDRESS >>SYS:LOGIN\LOGINS\%LOGIN_NAME
no keys------
It closes automatically, but I am only doing an echo, not a batch file. The batch files are the ones giving me fites.Thanks for all the suggestions, but nothing has worked yet.
Shane

I had the same problem.
and the solution is as follow:
1. Put The Command EXIT in the end of the bat file.
2. Then Do Right Click On The Bat File Then Go To Properties -> Program There You Will See A Check Box
With The Label "Close On Exit" Make Sure It Is Mark On.Thats All It Should Work For You As It Work For Me.

Try using the call or start command to invoke one batch from another. Syntax:
CALL batch.bat
or
START batch.batMight work.

If you are in a true 32-Bit env (NT/2K/XP)use the following commands as a guide. Just Cut and past it and run it. This will shell out and exit the shell it is in.
@ echo off
cmd /q /c "net use lpt1 /delete > nul"
cmd /q /c "net use lpt1 \\dynamics\xerox > nul"

I had the same problem on NT and Win2k.
I argree, put the EXIT command at the end of the login script listed in the User profile.
Worked for me.
Good luck

Sorry about the last post. My fingers were typing faster than my brain was thinking.
What I meant to say was that I put the EXIT command at the end of the batch file that is INSIDE the script that is listed in the user profile.
Sorry about the confusion.

I was running into the same problem and needed a coding solution since this batch file will be used on multiple machines and using PIF's is not an option. After doing some research, I found that although the Exit command ends the session with DOS, this does not necessarly close the window if there is something to display. Add a CLS at the end of your batch code to clear the screen. This will cause the DOS window to close since there's nothing to display when it's done. Hope that helps.
Mike

Well very simple, all you need to do is right click the batch file > Properties goto to the next tab where you have the option "Close on Exit" select it, Apply then Ok and problem solved.
Any more probs just mail me : Help@Opti-Net.co.uk

Also, before EXIT, put CLS.
ONE of the reasons for a window not closing is because of data on the screen.
Since I found this out, I end all batch files run from within windows with
cls
exit

Thanks guys, this has been pretty helpful --
I have a bit of a challenge: I create a batch file programmatically, so I don't have the luxury of right clicking and setting the properties. Anyone know how to set these properties programmatically?

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

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