Computer Hope

Software => Computer programming => Topic started by: kil on June 29, 2006, 04:51:37 PM

Title: Batch popup message
Post by: kil on June 29, 2006, 04:51:37 PM
Is there anyway to popup a message with a batch script where the user has to click OK for the batch file to run?

I current have it so that it pops up a message and the user has to click OK and then Enter in the command prompt but this is a problem because the command prompt gets hidden behind another active window. Any help is appreciated.

============================================================
msg %username% Click OK and then Enter to start backup.
pause
============================================================

Also, if you can tell me if the following script can be shortened or rewritten so it is closer to scripting standards, that woudl be great.

==========================================================
msg %username% Click OK and then Enter to start backing up your Outlook Email

pause

if not exist "c:\Documents and Settings\%username%\My Documents\Outlook Backup\null" mkdir "c:\Documents and Settings\%

username%\My Documents\Outlook Backup"

if not exist "c:\Documents and Settings\%username%\My Documents\Outlook Backup\Archive\null" mkdir "c:\Documents and

Settings\%username%\My Documents\Outlook Backup\Archive"

xcopy "c:\Documents and Settings\%username%\My Documents\Outlook Backup\Current" "c:\Documents and Settings\%username%\My

Documents\Outlook Backup\Archive" /d/e/c/q/h/r/y

rmdir /S/Q "C:\Documents and Settings\%username%\My Documents\Outlook Backup\Current"

if not exist "c:\Documents and Settings\%username%\My Documents\Outlook Backup\Current\null" mkdir "c:\Documents and

Settings\%username%\My Documents\Outlook Backup\Current"

if "%TODAYDATE%"=="" set TODAYDATE=%date:~4,2%-%date:~7,2%-%date:~10,4%
if "%date:~2,1%"=="/" set TODAYDATE=%date:~0,2%-%date:~3,2%-%date:~6,4%

mkdir "c:\Documents and Settings\%username%\My Documents\Outlook Backup\Current\%todaydate%"

taskkill /IM outlook.exe

ping -n 60 127.0.0.1>nul

xcopy "c:\documents and settings\%username%\local settings\application data\microsoft\outlook" "c:\Documents and Settings\%

username%\My Documents\Outlook Backup\Current\%todaydate%" /d/e/c/q/h/r/y

for /f %%i in ('date /t') do (
      if %%i==Fri if exist "c:\Documents and Settings\%username%\My Documents\Outlook Backup\Current\**-**-****" rmdir /S/Q

"C:\Documents and Settings\%username%\My Documents\Outlook Backup\Archive\"
      )
msg %username% The backup has completed. Click OK to close.
============================================================
Title: Re: Batch popup message
Post by: Sidewinder on June 29, 2006, 05:34:51 PM
You could try using the msg command with the /time:xx and the /w switches. Used correctly you can eliminate the pause with it's additional interrupt to the console.

Batch files? Standards? ;D You're kidding, right? Writing batch language has been an exercise in spaghetti code since 1980. If your code works, don't mess with it.

 8-)
Title: Re: Batch popup message
Post by: kil on June 29, 2006, 09:12:38 PM
Thanks for the help...the "msg /W" works great.