TomGee.us

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*
Archive a folder
  • “C:\Program Files\7-Zip\7z” a -tzip D:\Zips\Data_20100801.zip D:\Output\Data_20100801
Leave a Comment :, , , , , , , , , , , more...

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:

@echo off
:: variables
set drive=F:\Backup
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo Starting Backup – %date% %time% >> %drive%\backup.log
echo ### Backing up Documents…
echo   Documents >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Documents” “%drive%\Documents”
echo ### Backing up Pictures…
echo   Pictures >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Pictures” “%drive%\Pictures”
echo ### Backing up Desktop…
echo   Desktop >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Desktop” “%drive%\Desktop”
echo ### Backing up Downloads…
echo   Downloads >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Pictures” “%drive%\Downloads”
echo ### Backing up Favorites…
echo   Favorites >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Favorites” “%drive%\Favorites”
echo ### Backing up Music…
echo   Music >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Music” “%drive%\Music”
echo ### Backing up Videos…
echo   Videos >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Videos” “%drive%\Videos”
echo Backup Complete!
echo Backup Complete – %date% %time% >> %drive%\backup.log
Click [this link] to download the above batch script and enjoy!

1 Comment :, , , , more...

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

Leave a Comment : more...

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

Leave a Comment : more...

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

Leave a Comment : more...

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

Leave a Comment : more...

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
  • 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
Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!