Aubs
asked on
Batch file command - While waiting for a process to finish, display timer or similar
Hi,
I have a batch file that is run when people log on to the network.
Basically it uses:
net use m: \\OurServer\Folder
to map drives on the local machine to the server.
Sometimes this can take a minute or so to complete.
I would like, somehow, to display a message something like:
echo Creating Network Drive. Please wait.
echo Creating Network Drive. Please wait..
echo Creating Network Drive. Please wait...
echo Creating Network Drive. Please wait....
echo Creating Network Drive. Please wait.....
echo Creating Network Drive. Please wait......
echo Creating Network Drive. Please wait.......
but for it to all appear on ONE line.
Another option is:
echo Creating Network Drive. Please wait |
echo Creating Network Drive. Please wait /
echo Creating Network Drive. Please wait -
echo Creating Network Drive. Please wait \
but again on one line.
It would be preferred that this happens when "net use m: \\OurServer\Folder" is called, so they happen cuncurently.
Thanks in advance for your help :)
Aubs
I have a batch file that is run when people log on to the network.
Basically it uses:
net use m: \\OurServer\Folder
to map drives on the local machine to the server.
Sometimes this can take a minute or so to complete.
I would like, somehow, to display a message something like:
echo Creating Network Drive. Please wait.
echo Creating Network Drive. Please wait..
echo Creating Network Drive. Please wait...
echo Creating Network Drive. Please wait....
echo Creating Network Drive. Please wait.....
echo Creating Network Drive. Please wait......
echo Creating Network Drive. Please wait.......
but for it to all appear on ONE line.
Another option is:
echo Creating Network Drive. Please wait |
echo Creating Network Drive. Please wait /
echo Creating Network Drive. Please wait -
echo Creating Network Drive. Please wait \
but again on one line.
It would be preferred that this happens when "net use m: \\OurServer\Folder" is called, so they happen cuncurently.
Thanks in advance for your help :)
Aubs
ASKER
Hi Dr.!
Any suggestions on an external app I assume the app can reside on the server?
Thanks,
Aubs
Any suggestions on an external app I assume the app can reside on the server?
Thanks,
Aubs
Hi Aubs,
sorry, not off the top of my head, no. However, I shall do a bit of hunting now for you. And yes, it should be able to reside on the server.
[r.D]
sorry, not off the top of my head, no. However, I shall do a bit of hunting now for you. And yes, it should be able to reside on the server.
[r.D]
Okay, I've found something. I shall create you some script, etc, then post it all here. So, give me a short while..
[r.D]
[r.D]
ASKER
Great, thanks Dr.
I know you can use either choice or ping but they don't do the 'moving bits'!
Will increase the points for you :)
Aubs
I know you can use either choice or ping but they don't do the 'moving bits'!
Will increase the points for you :)
Aubs
ASKER
Will not be able to look at it till tomorrow as will not have any net connection!
Thanks again though!
Aubs.
Thanks again though!
Aubs.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oops.. it needs a bit of alteration that I forgot to do. I'll sort it now.
[r.D]
[r.D]
Okay, in the above code, replace this line:
START %Command% (?)
with:
START /MIN %Command%
That should do it ^_^
[r.D]
START %Command% (?)
with:
START /MIN %Command%
That should do it ^_^
[r.D]
You can also accomplish the task by writing a command tag file to signal when you are done. The example doesn't write the message on one line, but it accomplishes the task. For example:
@echo off
start /B GetShare.bat >NUL
:AGAIN
if exist %temp%\_done.dat goto DONE
echo Please wait...
PING -n 2 localhost >NUL
goto :AGAIN
:DONE
del %temp%\_done.dat >NUL
---- GetShare.bat
@echo off
if exist %temp%\_done.dat del %temp%\_done.dat>NUL
net use g: \\server\share 2>NUL >NUL
echo Done>%temp%\_done.dat
exit
Good Luck,
Steve
@echo off
start /B GetShare.bat >NUL
:AGAIN
if exist %temp%\_done.dat goto DONE
echo Please wait...
PING -n 2 localhost >NUL
goto :AGAIN
:DONE
del %temp%\_done.dat >NUL
---- GetShare.bat
@echo off
if exist %temp%\_done.dat del %temp%\_done.dat>NUL
net use g: \\server\share 2>NUL >NUL
echo Done>%temp%\_done.dat
exit
Good Luck,
Steve
ASKER
Dr.
Thanks for that, seems to work well, however it does cls every time.
Steve,
Yours does exactly the same as Dr.'s however does not need an external program.
The only concern I have, is removing the /B switch from the START, shows it doesn't actually do anything.
It seems as if it opens a new command prompt but then does nothing, and the same happens when the /B switch is used.
Also, the fact that the _done.dat isn't created by the GetShare.bat shows it isn't run.
Any suggestions? - I think this method may be more ideal than the one by Dr., but only if it works!!
Thanks again :)
Virtually the same scenareo, the screen is up to this point:
::::START
Logging you on to the network.
Starting to create your network drives.
Please be patient...
Connecting to G Drive...
Processing...
Processing......
Processing.........
::::END
BUT, the last 3 lines on the same line, so the dots move while leaving the rest of the screen intact.
Is there no way to do it?
Would it need to gather the information from the buffer of the command prompt? - Is that possible?
and cls then paste the info?
Thanks in advance!
Aubs
Thanks for that, seems to work well, however it does cls every time.
Steve,
Yours does exactly the same as Dr.'s however does not need an external program.
The only concern I have, is removing the /B switch from the START, shows it doesn't actually do anything.
It seems as if it opens a new command prompt but then does nothing, and the same happens when the /B switch is used.
Also, the fact that the _done.dat isn't created by the GetShare.bat shows it isn't run.
Any suggestions? - I think this method may be more ideal than the one by Dr., but only if it works!!
Thanks again :)
Virtually the same scenareo, the screen is up to this point:
::::START
Logging you on to the network.
Starting to create your network drives.
Please be patient...
Connecting to G Drive...
Processing...
Processing......
Processing.........
::::END
BUT, the last 3 lines on the same line, so the dots move while leaving the rest of the screen intact.
Is there no way to do it?
Would it need to gather the information from the buffer of the command prompt? - Is that possible?
and cls then paste the info?
Thanks in advance!
Aubs
ASKER
even using two test files:
FILE 1 a01.bat
@echo off
set TEMPFILE="C:\Documents and Settings\beeslea\Desktop\B atch\a02.b at"
echo a
echo b
echo %TEMPFILE%
start /MIN %TEMPFILE%
start %TEMPFILE%
echo c
echo d
FILE 2 a02.bat
@echo off
echo 1
echo 2
echo 3
echo 4
All I get is:
PROMPT 1:
C:\>"C:\Documents and Settings\beeslea\Desktop\B atch\a01.b at"
a
b
"C:\Documents and Settings\beeslea\Desktop\B atch\a02.b at"
c
d
C:\>
PROMPT 2:
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>
FILE 1 a01.bat
@echo off
set TEMPFILE="C:\Documents and Settings\beeslea\Desktop\B
echo a
echo b
echo %TEMPFILE%
start /MIN %TEMPFILE%
start %TEMPFILE%
echo c
echo d
FILE 2 a02.bat
@echo off
echo 1
echo 2
echo 3
echo 4
All I get is:
PROMPT 1:
C:\>"C:\Documents and Settings\beeslea\Desktop\B
a
b
"C:\Documents and Settings\beeslea\Desktop\B
c
d
C:\>
PROMPT 2:
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>
ASKER
Is this demonstrating that the first batch does not (or if it does it is ignored) pass the batch file to run to the START command?
Thanks to you both for your inspiration and I hope we get this working!!
I've also increased the points which I think may be split between you both if we get it working!! (unless someone else pops in with an outstanding solution!!!)
Aubs
Thanks to you both for your inspiration and I hope we get this working!!
I've also increased the points which I think may be split between you both if we get it working!! (unless someone else pops in with an outstanding solution!!!)
Aubs
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This should do what you want. Put sleep.exe (from the W2k3 Resource Kit Tools) into the netlogon share as well (you can do it with a ping as well, but why misuse a command if a proper one exists). You can vary the time between the dots by editing the sleep command in the loop.
Once the net use command is finished, the result will be displayed (type "%LogFile%"); the second sleep right before that is needed for the net use command to release the file. You can of course delete the "sleep" and "type" lines if you don't need to see the result.
@echo off
setlocal
set LogFile=%Temp%\%~n0.tmp%
if exist "%LogFile%" del "%LogFile%"
<NUL set /p Dummy=Creating network drive
start "" /b cmd /s /c "net use g: \\server\share 1>"%LogFile%" 2>&1"
:loop
<NUL set /p Dummy=.
sleep 2
if not exist "%LogFile%" goto :loop
echo done.
sleep 1
type "%LogFile%"
del "%LogFile%"
Once the net use command is finished, the result will be displayed (type "%LogFile%"); the second sleep right before that is needed for the net use command to release the file. You can of course delete the "sleep" and "type" lines if you don't need to see the result.
@echo off
setlocal
set LogFile=%Temp%\%~n0.tmp%
if exist "%LogFile%" del "%LogFile%"
<NUL set /p Dummy=Creating network drive
start "" /b cmd /s /c "net use g: \\server\share 1>"%LogFile%" 2>&1"
:loop
<NUL set /p Dummy=.
sleep 2
if not exist "%LogFile%" goto :loop
echo done.
sleep 1
type "%LogFile%"
del "%LogFile%"
There is no batch method to do it without CLS.
I would recommend SteveGTR's solution because it does not require any extra programs and solves the problem as well as possible.
I would recommend SteveGTR's solution because it does not require any extra programs and solves the problem as well as possible.
Good information was submitted by myself, DrWarezz, and oBdA. A three way split would work here.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh, and splitting is fine by me. This one was fun.
oBdA, a new trick! Excellent!!
I'll revise my recommended split to:
100 to DrWarezz
200 to oBdA
Thanks :)
I'll revise my recommended split to:
100 to DrWarezz
200 to oBdA
Thanks :)
ASKER
WOW, Sorry for the absentee-ism (sp.!)
I would like to thank you all for your help in this issue, and I think I agree with Steve, in that the points should be split, however, I think Steve deserves some too, so I'll up the points a little.
I will assign this now.
Thanks again ppl. and I'm glad you had some fun oBdA!
Aubs
I would like to thank you all for your help in this issue, and I think I agree with Steve, in that the points should be split, however, I think Steve deserves some too, so I'll up the points a little.
I will assign this now.
Thanks again ppl. and I'm glad you had some fun oBdA!
Aubs
[r.D]