Computer Hope

Microsoft => Microsoft DOS => Topic started by: mcolli00 on April 21, 2009, 09:28:58 AM

Title: How to - If user clicks EXIT then unmount (popd) network drive
Post by: mcolli00 on April 21, 2009, 09:28:58 AM
I have a batch file that mounts a drive and runs various scripts on a network drive. Once the scripts completes the drive automatically unmounts.  If the user clicks the exit button on the dos window I would like to unmount the drive.  Do you know how unmount a drive if the user exits the batch operation? Thanks MC


IF EXIT popd \\mynetwork

Title: Re: How to - If user clicks EXIT then unmount (popd) network drive
Post by: BumFacer on April 21, 2009, 09:51:37 AM
Why don't you just run the batch file in the background so user can't exit it by closing the prompt? Or do I not understand the problem?
Title: Re: How to - If user clicks EXIT then unmount (popd) network drive
Post by: macdad- on April 21, 2009, 11:09:52 AM
This is not possible if you mean "DOS" in Windows, since that is actually CMD.

You can't unmount a drive in CMD.
Title: Re: How to - If user clicks EXIT then unmount (popd) network drive
Post by: mcolli00 on April 21, 2009, 11:30:28 AM
I have the mounting and unmounting working fine. Users test the scripts so they are allowed the flexibility to kill a batch if needed.

I just wanted to know if you can use

if Exit then do something...
Title: Re: How to - If user clicks EXIT then unmount (popd) network drive
Post by: macdad- on April 21, 2009, 12:12:04 PM
Oh i see what your using, Popd, haven't seen that in a while.

And no you can't check to see if the batch file closes then do something, it's not possible in batch.
Title: Re: How to - If user clicks EXIT then unmount (popd) network drive
Post by: mcolli00 on April 21, 2009, 12:29:43 PM
Alrighty thanks :-)
Title: Re: How to - If user clicks EXIT then unmount (popd) network drive
Post by: devcom on April 21, 2009, 02:25:50 PM
you can compile somebatfile.bat to someexefile.exe wich will create subbatfile.bat. That subbatfile.bat will check if that compiled someexefile.exe is running or no  ;D
Title: Re: How to - If user clicks EXIT then unmount (popd) network drive
Post by: macdad- on April 21, 2009, 03:17:47 PM
yes, but if he means run whatever commands on program termination then thats not possible.