Restore MSSQL database using batch script


If you are looking for a tool which can restore the MS SQL DB backup from the production environment to the development environment, this script is just the one that you are after. In my example, the script does the following things: 1) Copy of the latest pro db backup to local. 2) Close all connections of … Continue reading Restore MSSQL database using batch script

WinSCP or Putty authenticates against Microsoft ISA/ TMG


Many companies use Microsoft ISA/ TMG as their enterprise proxy solution. This may work for most cases. But in some scenarios, it does not work well. For example, use WinSCP or Putty behind the proxy AND the proxy requires authentication. ISA/ TMG is mircrosoft technology, it uses NTLM based authentication which is not supported by … Continue reading WinSCP or Putty authenticates against Microsoft ISA/ TMG

Use batch script to add wireless user in HP MSM720 AP


I wrote a simple batch script to simplify the process of adding a new wireless user in the HP MSM720 AP for our network guy. It also includes a log file which keeps all the detailed information of what happened while executing the commands in the AP. @echo off cd /d %~dp0 set ADMIN=root set … Continue reading Use batch script to add wireless user in HP MSM720 AP

IIS Log Archive Script


@ECHO OFF set script_dir=C:\scripts\w3c set iislog_dir=C:\WINDOWS\system32\LogFiles\W3SVC1 set backup_dir=%Date:~-4,4%-%Date:~-10,2%-%Date:~-7,2%-%Time:~-11,2%'%Time:~-8,2%'%Time:~-5,2% set archive_dir=\\File_Server\Log_Archive\%COMPUTERNAME%\W3SVC1 C: cd %iislog_dir% REM ====Create a backup folder named after Today's date========================== mkdir %backup_dir% echo Subject: %COMPUTERNAME% W3C Log Archive Report > %script_dir%\log.txt echo.>> %script_dir%\log.txt date /t >> %script_dir%\log.txt echo. >> %script_dir%\log.txt REM ====Move logs that older than 30 days to the backup folder=================== echo … Continue reading IIS Log Archive Script

Auto Enable or Disable IE Proxy


It is painful to turn on/off the IE proxy manually in office/home. I wrote up a simple batch script to detect the location and automatically enable/disable the proxy when I login. @echo off REM Auto enable/disable IE proxy settings REM Define your proxy server here set proxy-server=my-proxy-server REM Enter the script path cd D:\scripts\batch REM … Continue reading Auto Enable or Disable IE Proxy

Create_User.bat


@ECHO OFF REM Get username and password from user's input set var1=%1 set var2=%2 REM Don't allow user to change password NET USER %var1% %var2% /add /expires:never /passwordchg:no REM User's password never expire wmic useraccount where "Name='%var1%'" set Passwordexpires=false REM Add user to remote desktop group NET localgroup "Remote Desktop Users" %var1% /add REM Create … Continue reading Create_User.bat

WMIC Examples


I did not get many chances to use WMIC (Windows Management Instrumentation Command-line) before, but recently I have used it twice and found it is really handy! Example 1: Get local user SID wmic useraccount get name,sid Example 2: Set a local user’s password never expire wmic useraccount where "Name='user01'" set Passwordexpires=false