Need some help creating a batch file

August 2, 2009 at 12:44:00
Specs: Windows XP
Hello Guys ,
I am trying to create a dos program .
With the help of this we can add a reminder in windows XP.
At the specified time a POP-UP Command windows will come up and show the messge provided by you.

It all works fine when i create two batch files and put them in system32.

What i would like to do is to create a single batch file name createalarm.bat.

When i run it should create 2 saprate batch files in system32. 1) alarm.bat 2) showalarm.bat


Please go through below script..

@ECHO OFF
echo @ECHO OFF>>%systemroot%\system32\alarm.bat
echo Title **************Pop-up Reminder by Subhash Chandra************************>>%systemroot%\system32\alarm.bat
echo Color f>>%systemroot%\system32\alarm.bat
echo echo.>>%systemroot%\system32\alarm.bat
echo echo.>>%systemroot%\system32\alarm.bat
echo echo.>>%systemroot%\system32\alarm.bat
echo setlocal>>%systemroot%\system32\alarm.bat
echo set /p tm= Enter the time to set the Reminder :>>%systemroot%\system32\alarm.bat
echo set /p ds= Input the description for this Reminder :>>%systemroot%\system32\alarm.bat
echo ECHO reminder successfully Set at %tm% to %DS%>>%systemroot%\system32\alarm.bat
echo at %tm% /interactive "cmd.exe" /k showalarm "%DS%">>%systemroot%\system32\alarm.bat
echo set /p ent=Press Enter to Exit………>>%systemroot%\system32\alarm.bat
echo exit>>%systemroot%\system32\alarm.bat
echo Title **************Pop-up Reminder by Subhash Chandra************************ >>%systemroot%\system32\showalarm.bat
echo Color f >>%systemroot%\system32\showalarm.bat
echo echo. >>%systemroot%\system32\showalarm.bat
echo echo. >>%systemroot%\system32\showalarm.bat
echo echo. >>%systemroot%\system32\showalarm.bat
echo echo. >>%systemroot%\system32\showalarm.bat
echo echo. >>%systemroot%\system32\showalarm.bat
echo echo %1 >>%systemroot%\system32\showalarm.bat
echo echo. >>%systemroot%\system32\showalarm.bat
echo echo. >>%systemroot%\system32\showalarm.bat
echo set /p ent= Press Enter to exit ........ >>%systemroot%\system32\showalarm.bat
Set /p ddnkn= Press enter to exit


This will create a file named alarm.bat and another named showalarm.bat in system 32.

Both files are being created but in both of them at line echo "at %tm% /interactive "cmd.exe" /k showalarm "%DS%"">>%systemroot%\system32\alarm.bat" the {%} is not showing in output file.

ANy help will greatly appriciated.

Thanks in advanced.

Subhash Chandra.

Subhash Chandra.


See More: Need some help creating a batch file

Report •


#1
August 2, 2009 at 16:11:20
Both files are being created but in both of them at line echo "at %tm% /interactive "cmd.exe" /k showalarm "%DS%"">>%systemroot%\system32\alarm.bat" the {%} is not showing in output file.

In order to echo % you must double it up such as %%DS%%

Suggest you could reduce your coding by using something like:

(
echo @ECHO OFF
echo Title **************Pop-up Reminder by Subhash Chandra************************
echo Color f
echo echo.&echo.&echo.

echo setlocal

echo set /p tm= Enter the time to set the Reminder :
echo set /p ds= Input the description for this Reminder :
echo ECHO reminder successfully Set at %tm% to %DS%
echo at %tm% /interactive "cmd.exe" /k showalarm "%DS%"
echo set /p ent=Press Enter to Exit………
echo exit
)>>%systemroot%\system32\alarm.bat

Instead of:


echo @ECHO OFF>>%systemroot%\system32\alarm.bat
echo Title **************Pop-up Reminder by Subhash Chandra************************>>%systemroot%\system32\alarm.bat
echo Color f>>%systemroot%\system32\alarm.bat
echo echo.>>%systemroot%\system32\alarm.bat
echo echo.>>%systemroot%\system32\alarm.bat
echo echo.>>%systemroot%\system32\alarm.bat
echo setlocal>>%systemroot%\system32\alarm.bat
echo set /p tm= Enter the time to set the Reminder :>>%systemroot%\system32\alarm.bat
echo set /p ds= Input the description for this Reminder :>>%systemroot%\system32\alarm.bat
echo ECHO reminder successfully Set at %tm% to %DS%>>%systemroot%\system32\alarm.bat
echo at %tm% /interactive "cmd.exe" /k showalarm "%DS%">>%systemroot%\system32\alarm.bat
echo set /p ent=Press Enter to Exit………>>%systemroot%\system32\alarm.bat
echo exit>>%systemroot%\system32\alarm.bat


Same sort of thing could be done for ShowAlarm.bat

Good luck.


Report •

#2
August 2, 2009 at 16:22:41
Hmmm.

I was just lost the hope that I can do it!!

I learned 2 things now,

first the way you reduced the script was amezing and second the %% %% thing.

I dont have word to say ( just Thank you is not enough )
I really really appreciate your help.


YOU ARE THE BATCH GURU...

Subhash Chandra.

Subhash Chandra.


Report •

Related Solutions


Ask Question