Scripts
7-Zip Command Lines (Windows)
by Tom Gee on Aug.09, 2010, under Scripts
To extract all .zip files in the specified directory and make a new folder in the current directory for the extract that has the same name as the .zip file:
- D:\Unzipped>”c:\Program Files\7-Zip\7z.exe” x d:\Zips\*.zip -o*
- “C:\Program Files\7-Zip\7z” a -tzip D:\Zips\Data_20100801.zip D:\Output\Data_20100801
Backup PC via Batch Script
by Tom Gee on Apr.25, 2010, under Scripts
I made a few small alterations to the script found [http://www.speedguide.net/read_articles.php?id=1547] and use it on a regular basis to backup my Windows 7 PC.
The source code is as follows, where F:\Backup is the location on my external drive where I want my files to be copied to:
Start/Stop SQL Server Express Service
by Tom Gee on Nov.16, 2009, under Scripts
Start the SQL Server service
@ECHO OFF
NET START MSSQL$SQLEXPRESS
Stop the SQL Server service
@ECHO OFF
NET STOP MSSQL$SQLEXPRESS
View user session information on remote machines
by Tom Gee on Nov.16, 2009, under Scripts
Copy and paste this into a blank text file and save the file with a .bat extension.
@echo off
rem ######################################################################
rem Program Name: Server_Session.bat
rem Developer: Tom Gee
rem Develop Date: 13-JUL-2007
rem Revision: 1.00
rem How to use: Find the NT IDs of the user(s) currently logged into a specific server and reset if desired
rem ######################################################################
title View Server Session(s)
:Begin
SET /P SERVER=Enter the server name or IP address you would like to examine:
echo.
qwinsta /server:%SERVER%
echo.
SET /P RESET=Would you like to reset a user’s session? (Y / N)
if %RESET%==Y goto YES
if %RESET%==N goto NO
if %RESET%==y goto YES
if %RESET%==n goto NO
:YES
echo.
SET /P USERID=What user ID would you like to reset?
rwinsta /server:%SERVER% %USERID%
:NO
echo.
echo Execution Complete.
echo.
SET /P RERUN=Would you like to examine another server? (Y / N)
echo.
if %RERUN%==Y goto Begin
if %RERUN%==y goto Begin
pause
Ping remote machines to test network connectivity
by Tom Gee on Nov.16, 2009, under Scripts
Copy and paste this into a blank text file and save the file with a .bat extension.
@echo off
rem ######################################################################
rem Program Name: Pinger.bat
rem Developer: Tom Gee
rem Develop Date: 13-JUL-2008
rem Revision: 1.00
rem How to use: Ping a specified server to see if it’s online and check response time
rem ######################################################################
title PC Pinger
:Begin
SET /P SERVER=Enter the server name or IP address you would like to ping:
echo.
:Recheck
ping %SERVER%
echo.
echo Execution Complete.
echo.
rem SET /P RERUN=Would you like to examine another server? (Y / N)
SET /P RERUN=Would you like to re-check the same server? (Y / N)
echo.
if %RERUN%==Y goto Recheck
if %RERUN%==y goto Recheck
pause
View system summary for remote PC
by Tom Gee on Nov.16, 2009, under Scripts
Copy and paste this into a blank text file and save the file with a .bat extension.
@echo off
rem ######################################################################
rem Program Name: MSINFO32.bat
rem Developer: Tom Gee
rem Develop Date: 08-AUG-2008
rem Revision: 1.00
rem How to use: View server hardware details
rem ######################################################################
title Remote Server Spec Viewer
:Begin
SET /P SERVER=Enter the server name to view info for:
echo.
cd C:\Program Files\Common Files\Microsoft Shared\MSInfo
msinfo32.exe /computer \\%SERVER%
echo Execution Complete.
echo.
SET /P RERUN=Would you like to examine another server? (Y / N)
echo.
if %RERUN%==Y goto Begin
if %RERUN%==y goto Begin
pause
Handy DOS commands
by Tom Gee on Nov.15, 2009, under Scripts
- dir – Shows a list of files and subdirectories in a directory.
- /O – Order the list results
- D – by date/time (oldest first)
- E – by file extension (A-Z)
- G – group directories first
- N – by name (A-Z)
- S – by size (smallest first)
- /P – Pauses after each screen of information
- /Q - Display owner of the file
- /S – Include contents of subdirectories
- /T - Control which time field is used for sorting
- A – Last access
- W – Last written
- /4 – Show 4-digit year
- /O – Order the list results
- findstr – searches through text in files for a specified string value
- /I – Make the search not case sensitive
- /M – Print only the filename of file that contains a match
- /N – Print the line number
- /P – Skip files with non-printable characters
- /S – Search in all subdirectories
findstr /I /M “chocolate” c:\Recipes\*.*
- nslookup – DNS lookup/Traceroute
- ren – Rename all files in a directory. The following example will replace the .sql file extension for all files in the current directory with .txt.
ren *.sql *.txt
- xcopy – Copies files and directories
- %~d0%~p0 – Shows the path of the current directory
- %~f0 - The full path of the current batch file