Technical Forums (Troubleshooting)

This will provide you easy trouble shooting.

Thursday, October 6, 2011

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>

Thanks.

Tuesday, October 4, 2011

IP Messenger (Chat on your local network)

The ‘IP Messenger’ works similar to a LAN chat application there by offering the users to chat
textually within the same network. The hostname of the recipient is good enough to chat with them.

Copy and paste the above program in a notepad file and save it as a batch file, you will be getting 
a pop up windows that exactly looks like below screenshot, when you execute the batch file,In the user field you have to enter the system name of the recipient, and in the message field type 
in the message that you wanna convey to the recipient. You may use multiple chat with various persons at 
the same time.
Copy , paste this code on notepad and save as with bat extension (like chat.bat).
Script:
  1. @echo off
  2. :loop
  3. Title LAN CHAT
  4. color a
  5. Cls
  6. echo                     ########## LAN CHAT ##########
  7. echo.
  8. echo Type in the hostname of the recipient in the User: Field
  9. echo Enter the Message you wanna convey to the recipient in the Message: Field
  10. echo.
  11. set /p n=User:
  12. set /p m=Message:
  13. net send %n% %m%
  14. Pause
  15. Goto loop
Thanks.

How to lock Folder in Windows

If you want locking up your folder with a password, so the user who
knows the right password can only be able to access the folder, where others don’t (Well this is not quite
secure, but can be useful in learning batch programming, because even a noob can easily identify the
password, or can access the folder without using a password, there are a lot of ways to break it).
The batch file that is given below will create a directory named ‘Locker’, when it gets executed,
then you may place whatever you wish to place inside that directory, once done re-execute the same batch
file, then it will prompt you whether to lock the folder,  like this
press ‘y’ and hit enter, then the directory ‘Locker’ Disappears. In order to make the directory re-appear
again, you have to execute the same batch file once again, then it will prompt you to enter the password to
unlock the folder, you have to enter the password as ‘secret’, since it is already mentioned by default in
the program itself.
Once the password is matched, then the folder becomes visible, so that you can access the folder again.
So, what happens is that, the folder ‘Locker’ is set with the system and hidden attribute, hence it becomes
invisible, when the batch program is executed again, it prompt for password, which is already set as an
environment variable with a value ‘secret’, when the match is found, the attribute is set to normal and the
folder becomes visible and accessible.
Here is the snippet for the folder locke.
Copy , paste this code on notepad and save as with bat extension (like lock.bat). 
 
Script:
  1. @echo off
  2. title Folder Locker
  3. if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
  4. if NOT EXIST Locker goto MDLOCKER
  5. :CONFIRM
  6. echo Are you sure u want to Lock the folder(Y/N)
  7. set/"cho=>"
  8. if %cho%==Y goto LOCK
  9. if %cho%==y goto LOCK
  10. if %cho%==n goto END
  11. if %cho%==N goto END
  12. echo Invalid choice.
  13. goto CONFIRM115
  14. :LOCK
  15. ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
  16. attrib ++"Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
  17. echo Folder locked
  18. goto End
  19. :UNLOCK
  20. echo Enter password to Unlock folder
  21. set/"pass=>"
  22. admin
  23. if NOT %pass%== secret goto FAIL
  24. attrib --"Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
  25. ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
  26. echo Folder Unlocked successfully
  27. goto End
  28. :FAIL
  29. echo Invalid password
  30. goto end
  31. :MDLOCKER
  32. md Locker
  33. echo Locker created successfully
  34. goto End
Thanks.

How many files and how much much disk space is used in a directory

How many files and how much much disk space is used in a directory and all its subdirectories. If called with the parameter /d it lists each subdirectory otherwise it just prints the total number of files and bytes. Actual disk space consumed is somewhat higher because of cluster slack. Figure about half of the cluster size times the number of files for overhead. 100 files with a cluster size of 8k wastes about 400K. A floppy with 512 byte clusters uses only 25K extra for the same 100 files.
Copy , paste this code on notepad and save as with bat extension (like space.bat). 
Script:
  1. @echo off
  2. if not '%1=='/goto justhowmuch
  3. dir /a-/s|find "i"|find /"Volume"|more
  4. goto done
  5. :justhowmuch
  6. dir /a-/s|find "file(s)"|sort /r|find /"f"|find "[1]"
  7. echo [1ATotal:
  8. :done
Thanks.