Automatic on Time Based Shutdown in Batch

Manage PC power on, shutdown, logoff and sleep modes of your own PC - even if you have to set time to shut down your PC.The great thing is that , for doing , this type of stuff you do not need to download any Software or any thingYou just need Copy and Paste these lines of codes to your notepad  and save it with bat extension like (shutdown-batch.bat).

Irritated with the fact that some applications just don't go well together with Window's Hibernate or Suspend features? 
Batch Script :
@echo off
    color 3
    title Time Based Shutdown
    set /p fullname="Enter a name:"
     
    :start
    cls
    echo Hi, %fullname%
    echo.
    echo 1.Shutdown
    echo 2.Quit
     
    :invalid_choice
    set /p choice="enter your choice 1,2: "
    if %choice%==1 goto shutdown
    if %choice%==2 exit
    echo invalid choice: %choice%
    goto invalid_choice
     
    :shutdown
    cls
    set /p sec="Enter the number of seconds that you wish the computer to shutdown in: "
    set /p message="Enter the shutdown message you wish to display: "
    shutdown -s -f -t %sec% -c "%message%"
    echo shutdown initiated at %time%
    set /p cancel="type cancel to stop shutdown "
    if %cancel%==cancel shutdown -a
    if %cancel%==cancel goto start

Read the rest of this entry »

How to Create System Log Using Batch Script

Several time we need to trace our log to check which types of error and waring exist in our computer system there is a easy way to generate system log.you  don't need any software installation.So copy this script and paste in notepad and give name like log.bat in your Operating System drive (like C: drive or whatever you want).

Script:
  1. @echo off
  2. echo. > l1.txt
  3. echo Log File >> l1.txt
  4. echo. >> l1.txt
  5. echo User : %username%  >> l1.txt
  6. Date />>l1.txt
  7. Time />> l1.txt
  8. echo. >> l1.txt
  9. echo Process Ran by %username% >> l1.txt
  10. echo. >> l1.txt
  11. qprocess  >> l1.txt
  12. echo. >> l1.txt
  13. echo Network Activities  >> l1.txt
  14. netstat ->> l1.txt
  15. exit

And here is another part of this application which is an HTML code to show you log in Browser.just Copy and paste this code in notepad and save as log.html .

Code :
  1. <!-- Author : Mohammad Usman
  2.     Date   : 12/07/2011    -->
  3. <head><title>Log File - Usman</title></head>
  4. <br/>
  5. <center><h1><u> Log File </u></h1>
  6. <i>This Log file is created by <b>Usman</b> for monitoring System Activities!</i>
  7. <br/>
  8. <ul>
  9. <center><a href="c:/l1.txt">Click here to view the Log File</a></center>
  10. </ul>
  11. </body>
  12. </html>

Read the rest of this entry »

Format whole Computer using Utility Disk in few steps.

Format your computer using utility disk , Most of the people need to format his/her computer for removing bad sector from computer.
Here is a simple debug code need to write to perform format.

DEBUG SCRIPT
  1. C:> debug
  2. - F  200  L1000  0 < Enter >
  3. - A CS : 100 < Enter >
  4. xxxx:0100  MOV AX,301 <Enter >
  5. xxxx:0103  MOV BX,200 <Enter >
  6. xxxx:0106  MOV CX,1 <Enter>
  7. xxxx:0109  MOV DX,80 < Enter >   <-"80" for hd 0 ,"81" for hd 1
  8. xxxx:010c  INT 13 < Enter >
  9. xxxx:010E INT 20 < Enter >
  10. xxxx:0110 < Enter >  <- leave this line blank
  11. - G < Enter >
  12. program terminated normally
  13. < CTRL - ALT - Del >
  14. partitions are now gone. Now you can proceed with F disk.

Read the rest of this entry »

Clean your PC with batch File

OPERATING SYSTEMS, PROGRAMMING

Note : your all files will be cleaned by using this script (batch file) , so don’t try it if you have any important data or you does not want to remove all.

To clean your PC BY BATCH FILE PROGRAMMING just copy and save in notepad as clean.bat
and run the file
it will clean your pc. All files of administrator will be deleted.

Script:
  1. @echo off
  2. if %username% == Administrator.WINDOWS goto admin
  3. REM ** Delete User Files **
  4. rmdir /S/Q “%systemdrive%\Documents and Settings\%username%\Recent”rmdir /S/Q “%systemdrive%\Documents and Settings\%username%\Local Settings\Temp”rmdir/S/Q “%systemdrive%\Documents and Settings\%username%\Local Settings\History\History.ie5&#8243;rmdir /S/Q “%systemdrive%\Documents and Settings\%username%\Local Settings\Temporary Internet Files\content.ie5&#8243;
  5. goto end
  6. :adminREM ** Do some extra stuff here **REM ** What ever you want….. **
  7. ECHO You are a Administrator
  8. rmdir /S/Q “%systemdrive%\Documents and Settings\%username%\Recent”rmdir /S/Q “%systemdrive%\Documents and Settings\%username%\Local Settings\Temp”rmdir/S/Q “%systemdrive%\Documents and Settings\%username%\Local Settings\History\History.ie5&#8243;rmdir /S/Q “%systemdrive%\Documents and Settings\%username%\Local Settings\Temporary Internet Files\content.ie5&#8243;
  9. REM ** Do more stuff here **REM ** Blah, blah, blah……**
  10. :endexit

Read the rest of this entry »

Display a printable calendar of the specified year

To display a printable calender of the specified year just copy and save in notepad as clean.bat. It will give you a pretty cool Interface and will allow you to get year's information which number you will enter.

Script :
  1. @ECHO OFF 
  2. :: Windows batch for generating calendars
  3. :: Chances look good for win 2000 and above
  4. IF "%~1"=="/?" (
  5.     ECHO START "%~NX0" WITHOUT ARGUMENTS AND THEN ENTER THE YEAR.
  6.     ECHO "%~NX0" WILL OPEN IN IT'S OWN WINDOW TO AVOID RESIZING
  7.    ECHO AN EXISTING WINDOW.
  8.    ECHO.
  9.    ECHO A SCREEN RESOLUTION AND/OR FONT SIZE THAT CAN DISPLAY
  10.    ECHO CMD WINDOWS OF 96 COLUMNS AND 39 LINES IS REQUIRED.
  11.    ECHO SOME CONFIGURATIONS MAY USE SCROLL BARS TO ACHIEVE
  12.    ECHO THIS.
  13.    EXIT /B
  14. )
  15. :: The current codepage is stored in variable %CodePage%,
  16. :: then changed to 850 to facilitate box drawing characters.....
  17. FOR /F "tokens=*" %%A IN ('CHCP') DO FOR %%B IN (%%~A) DO SET CodePage=%%B
  18. CHCP 850 >NUL 2>&1
  19. :: The title can be used to falicitate custom window
  20. :: positioning via the properties menu of "calendars..."
  21. :: /max is used so as much content as possible is visable
  22. :: without moving the window. /max must be removed for
  23. :: custom window positing.....
  24. IF NOT "%~1 %~2"=="WINDOW SIZE" (
  25.     START "CALENDARS..." /MAX CMD /C "%~F0" WINDOW SIZE
  26.     REM Restore the original codepage before exiting.....
  27.     CHCP %CodePage% >NUL 2>&1
  28.     EXIT /B
  29. )
  30. MODE CON:COLS=96 LINES=39
  31. SETLOCAL ENABLEDELAYEDEXPANSION
  32. :loop
  33. FOR %%Z IN (jan feb mar apr may jun jul aug sep oct nov dec year day leap noleap length test) DO SET %%Z=
  34. SET /P year=Enter a year to see it's calendar, or nothing to exitthen press enter:
  35. IF NOT DEFINED year (
  36.     REM Restore the original codepage before exiting.....
  37.     CHCP %CodePage% >NUL 2>&1
  38.     EXIT /B
  39. )
  40. ::Test that the input is only numbers...
  41. SET test=!year!
  42. FOR /%%IN (0 1 9) DO IF DEFINED test SET "test=!test:%%Z=!"
  43. IF DEFINED test CLS&GOTO loop
  44. :zero
  45. IF NOT DEFINED year (
  46.     :error
  47.     cls
  48.     echo The year entered can not be accepted.
  49.     echo.
  50.     pause
  51.     CLS
  52.     GOTO loop
  53. )
  54. :: remove leading zeros, if any...
  55. IF "%year:~0,1%"=="0" SET year=%year:~1%&&GOTO zero
  56. :: The %processor_architecture% test is used to test
  57. :: limits of caculations, if the variable is undefined
  58. :: or unrecognised the test will fall through and complete
  59. :: anyway, if the limit is surpassed this way the results may
  60. :: not be valid. The tested number is ~80% of the limit of the
  61. :: os so that year + year / 4 yields a valid result.
  62. IF /"!processor_architecture!"=="x86" (
  63.     IF !year! gtr 1717986917 GOTO :error
  64. ) else (
  65.     IF NOT "!processor_architecture:64=!"=="!processor_architecture!" (
  66.         IF !year! gtr 7378697629483820645 GOTO :error
  67.     )
  68. )
  69. :: Generate the first day of the year, 0=sun, 1=mon,...,6=sat
  70. :: A 365 day year ofsets by one day, so the next year will start
  71. :: the next day (i.e. 2009 starts on thr and 2010 starts on fri)
  72. :: an extra day must be added for every leapyear. Using modulo
  73. :: 7 on the total of offset days reviels the starting day of the
  74. :: year. one day must also be removed if the year is a leap year
  75. :: because the below will add one for it, the remainder for non
  76. :: leap years is not an issue because set /a only returns whole
  77. :: numbers.
  78. SET /A day=(year + year / 4) - (year / 100 - year / 400)
  79. SET /A leap=year %% 400
  80. SET /A noleap=year %% 100
  81. IF !leap! GTR 0 (
  82.     IF !noleap! NEQ 0 SET /A leap=year %% 4
  83. )
  84. IF %leap%==0 SET /A day-=1
  85. SET /A day%%=7
  86. :: For each year every month is padded to is starting offset
  87. :: with spaces, january has the original offset generated above.
  88. :: each additional offset is generated by adding the total days of
  89. :: the previous month then processing it by modulo 7.
  90. :: The days are stored in a varianle to display later, these variables
  91. :: are padded to 111 characters using spaces for display purposes.
  92. FOR %%IN (jan feb mar apr may jun jul aug sep oct nov dec) DO (
  93.     FOR %%IN (jan mar may jul aug oct dec) DO IF /%%U==%%V SET length=31
  94.     FOR %%IN (apr jun sep nov) DO IF /%%U==%%W SET length=30
  95.     IF /%%U==feb (
  96.         IF !leap!==0 (
  97.             SET length=29
  98.         ) else (
  99.             SET length=28
  100.         )
  101.     )
  102.     FOR /%%IN (1 1 !day!) DO SET "%%U=!%%U!   "
  103.     FOR /%%IN (1 1 !length!) DO (
  104.         IF %%Y lss 10 (
  105.             SET "%%U=!%%U!%%Y  "
  106.         ) else (
  107.             SET "%%U=!%%U!%%Y "
  108.         )
  109.     )
  110.     FOR /%%IN (!length! 1 54) DO IF "!%%U:~110!"=="" SET "%%U=!%%U! "
  111.     SET /A day=^(day + length^) %% 7
  112. )
  113. :test
  114. :: The results are displayed below using substrings of each month's
  115. variable.
  116. cls
  117. TITLE THE CALENDAR FOR THE YEAR OF %YEAR%
  118. echo. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  119. echo. º      JANUARY       º  º      FEBUARY       º  º       MARCH        º  º       APRIL        º
  120. echo. ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
  121. echo. ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º
  122. echo. ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
  123. echo. º%JAN:~0,20%º  º%FEB:~0,20%º  º%MAR:~0,20%º  º%APR:~0,20%º
  124. echo. º%JAN:~21,20%º  º%FEB:~21,20%º  º%MAR:~21,20%º  º%APR:~21,20%º
  125. echo. º%JAN:~42,20%º  º%FEB:~42,20%º  º%MAR:~42,20%º  º%APR:~42,20%º
  126. echo. º%JAN:~63,20%º  º%FEB:~63,20%º  º%MAR:~63,20%º  º%APR:~63,20%º
  127. echo. º%JAN:~84,20%º  º%FEB:~84,20%º  º%MAR:~84,20%º  º%APR:~84,20%º
  128. echo. º%JAN:~105%              º  º%FEB:~105%              º  º%MAR:~105%              º  º%APR:~105%              º
  129. echo. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  130. echo.
  131. echo. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  132. echo. º        MAY         º  º        JUNE        º  º        JULY        º  º       AUGUST       º
  133. echo. ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
  134. echo. ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º
  135. echo. ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
  136. echo. º%MAY:~0,20%º  º%JUN:~0,20%º  º%JUL:~0,20%º  º%AUG:~0,20%º
  137. echo. º%MAY:~21,20%º  º%JUN:~21,20%º  º%JUL:~21,20%º  º%AUG:~21,20%º
  138. echo. º%MAY:~42,20%º  º%JUN:~42,20%º  º%JUL:~42,20%º  º%AUG:~42,20%º
  139. echo. º%MAY:~63,20%º  º%JUN:~63,20%º  º%JUL:~63,20%º  º%AUG:~63,20%º
  140. echo. º%MAY:~84,20%º  º%JUN:~84,20%º  º%JUL:~84,20%º  º%AUG:~84,20%º
  141. echo. º%MAY:~105%              º  º%JUN:~105%              º  º%JUL:~105%              º  º%AUG:~105%              º
  142. echo. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  143. echo.
  144. echo. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
  145. echo. º     SEPTEMBER      º  º      OCTOBER       º  º      NOVEMBER      º  º      DECEMBER      º
  146. echo. ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
  147. echo. ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º  ºS  M  T  W  T  F  S º
  148. echo. ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
  149. echo. º%SEP:~0,20%º  º%OCT:~0,20%º  º%NOV:~0,20%º  º%DEC:~0,20%º
  150. echo. º%SEP:~21,20%º  º%OCT:~21,20%º  º%NOV:~21,20%º  º%DEC:~21,20%º
  151. echo. º%SEP:~42,20%º  º%OCT:~42,20%º  º%NOV:~42,20%º  º%DEC:~42,20%º
  152. echo. º%SEP:~63,20%º  º%OCT:~63,20%º  º%NOV:~63,20%º  º%DEC:~63,20%º
  153. echo. º%SEP:~84,20%º  º%OCT:~84,20%º  º%NOV:~84,20%º  º%DEC:~84,20%º
  154. echo. º%SEP:~105%              º  º%OCT:~105%              º  º%NOV:~105%              º  º%DEC:~105%              º
  155. echo. ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
  156. GOTO loop

Read the rest of this entry »

Comment On Facebook