Backup Computer to VHD

@Echo off

REM A simple backup system using disk2vhd
REM requires ‘disk2vhd.exe’ to be in the path

setLocal EnableDelayedExpansion

REM “DRIVES” can be one drive identifier with colon, multiple separated by spaces,
REM or asterisk for all.
REM “DEST” can be a drive letter or a UNC.

SET DRIVES=”*”
SET DEST=”\\SERVER\SHARE”

REM Keep most recent 4 VHD files in DEST, delete the rest
for /f “skip=4 tokens=* delims= ” %%a in (‘dir/b/o-d %DEST%\*.VHD’) do (
del %DEST%\%%a
)

REM Backup to VHD
C:
cd \
DISK2VHD %DRIVES% %DEST%\D2VBK–%date:~-10,2%%date:~-7,2%%date:~-4,4%_TS.VHD

email me

Email via VBScript using CDO

The best way to use this script is to first create an email service account, and then just add the details of the service account to the below script. I also recommend compiling this script once you have it working with your email service account.

on error resume next

‘SET EMAIL CONTENT HERE – THIS COULD BE DYNAMIC CONTENT
GMail_Subject = “YourSubjectHere”‘This could be a username, topic, or other dynamic information
Gmail_Body = “Email Script” & vbCRLF & “Script created by Eddie Jackson” & vbCRLF & “Variables can be added here like bitlocker info, username, computer name, etc.”

‘MAIL OBJECTS
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0
Const cdoBasic = 1
Const cdoNTLM = 2

‘EMAIL ACCOUNT INFORMATION – ONLY NEEDS EMAIL SERVICE ACCOUNT INFO
Const strFrom = “HomeUsername@gmail.com”
Const strFromName = “FromInfoHere”
Const strTo = “EMAIL_ADDRESS_1@gmail.com,EMAIL_ADDRESS_2@gmail.com”‘who you want to receive the email
Const Gmail_SMTPServer = “smtp.gmail.com”
Const GMail_SMTPLogon = “EmailServiceAccountEmailAddressHere”’email service account
Const Gmail_SMTPPassword = “EmailServiceAccountPasswordHere”‘service account password
Const SMTPSSL = True
Const SMTPPort = 465

‘EXECUTES OBJECTS
Set objMessage = CreateObject(“CDO.Message”)
objMessage.Subject = GMail_Subject
objMessage.From = “””” & strFromName & “”” <” & strFrom & “>”
objMessage.To = strTo
objMessage.TextBody = Gmail_Body

objMessage.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
objMessage.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = Gmail_SMTPServer
objMessage.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”) = cdoBasic
objMessage.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/sendusername”) = GMail_SMTPLogon
objMessage.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/sendpassword”) = Gmail_SMTPPassword
objMessage.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = SMTPPort
objMessage.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpusessl”) = SMTPSSL
objMessage.Configuration.Fields.Item (“http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout”) = 60
objMessage.Configuration.Fields.Update

‘THIS SENDS THE MESSAGE
objMessage.Send

email me

Timeout Utility

TIMEOUT [/T] timeout [/NOBREAK]

Description:
This utility accepts a timeout parameter to wait for the specified
time period (in seconds) or until any key is pressed. It also
accepts a parameter to ignore the key press.

Parameter List:
/T timeout Specifies the number of seconds to wait.
Valid range is -1 to 99999 seconds.

/NOBREAK Ignore key presses and wait specified time.

/? Displays this help message.

NOTE: A timeout value of -1 means to wait indefinitely for a key press.

Examples:
TIMEOUT /?
TIMEOUT /T 10
TIMEOUT /T 300 /NOBREAK
TIMEOUT /T -1

email me

Batch – Dell BIOS Updater

This is a script I wrote to update BIOS versions from 3-16 on a Dell Laptop.

email me

@echo off
color 0a
title BIOS Updater 1.0

set BIOS_v03=E6410A03.exe /forceit /nopause /noreboot
set BIOS_v04=E6410A04.exe /forceit /nopause /noreboot
set BIOS_v05=E6410A05.exe /forceit /nopause /noreboot
set BIOS_v06=E6410A06.exe /forceit /nopause /noreboot
set BIOS_v07=E6410A07.exe /forceit /nopause /noreboot
set BIOS_v08=E6410A08.exe /forceit /nopause /noreboot
set BIOS_v09=E6410A09.exe /forceit /nopause /noreboot
set BIOS_v10=E6410A10.exe /forceit /nopause /noreboot
set BIOS_v11=E6410A11.exe /forceit /nopause /noreboot
set BIOS_v12=E6410A12.exe /forceit /nopause /noreboot
set BIOS_v13=E6410A13.exe /forceit /nopause /noreboot
set BIOS_v14=E6410A14.exe /forceit /nopause /noreboot
set BIOS_v15=E6410A15.exe /forceit /nopause /noreboot
set BIOS_v16=E6410A16.exe /forceit /nopause /noreboot
wmic bios get SMBIOSBIOSVersion | find “A02” && (
cls
ECHO Updating BIOS from A02 to A03rem %BIOS_v03%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…pending
echo BIOS update A04 to A05…pending
echo BIOS update A05 to A06…pending
echo BIOS update A06 to A07…pending
echo BIOS update A07 to A08…pending
echo BIOS update A08 to A09…pending
echo BIOS update A09 to A10…pending
echo BIOS update A10 to A11…pending
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A03” && (
cls
ECHO Updating BIOS from A03 to A04rem %BIOS_v04%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…pending
echo BIOS update A05 to A06…pending
echo BIOS update A06 to A07…pending
echo BIOS update A07 to A08…pending
echo BIOS update A08 to A09…pending
echo BIOS update A09 to A10…pending
echo BIOS update A10 to A11…pending
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A04” && (
cls
ECHO Updating BIOS from A04 to A05rem %BIOS_v05%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…pending
echo BIOS update A06 to A07…pending
echo BIOS update A07 to A08…pending
echo BIOS update A08 to A09…pending
echo BIOS update A09 to A10…pending
echo BIOS update A10 to A11…pending
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A05” && (
cls
ECHO Updating BIOS from A05 to A06rem %BIOS_v06%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…pending
echo BIOS update A07 to A08…pending
echo BIOS update A08 to A09…pending
echo BIOS update A09 to A10…pending
echo BIOS update A10 to A11…pending
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A06” && (
cls
ECHO Updating BIOS from A06 to A07rem %BIOS_v07%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…pending
echo BIOS update A08 to A09…pending
echo BIOS update A09 to A10…pending
echo BIOS update A10 to A11…pending
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A07” && (
cls
ECHO Updating BIOS from A07 to A08rem %BIOS_v08%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…pending
echo BIOS update A09 to A10…pending
echo BIOS update A10 to A11…pending
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A08” && (
cls
ECHO Updating BIOS from A08 to A09rem %BIOS_v09%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…done
echo BIOS update A09 to A10…pending
echo BIOS update A10 to A11…pending
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A09” && (
cls
ECHO Updating BIOS from A09 to A10rem %BIOS_v10%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…done
echo BIOS update A09 to A10…done
echo BIOS update A10 to A11…pending
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A10” && (
cls
ECHO Updating BIOS from A10 to A11rem %BIOS_v11%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…done
echo BIOS update A09 to A10…done
echo BIOS update A10 to A11…done
echo BIOS update A11 to A12…pending
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A11” && (
cls
ECHO Updating BIOS from A11 to A12rem %BIOS_v12%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…done
echo BIOS update A09 to A10…done
echo BIOS update A10 to A11…done
echo BIOS update A11 to A12…done
echo BIOS update A12 to A13…pending
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A12” && (
cls
ECHO Updating BIOS from A12 to A13rem %BIOS_v13%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…done
echo BIOS update A09 to A10…done
echo BIOS update A10 to A11…done
echo BIOS update A11 to A12…done
echo BIOS update A12 to A13…done
echo BIOS update A13 to A14…pending
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A13” && (
cls
ECHO Updating BIOS from A13 to A14rem %BIOS_v14%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…done
echo BIOS update A09 to A10…done
echo BIOS update A10 to A11…done
echo BIOS update A11 to A12…done
echo BIOS update A12 to A13…done
echo BIOS update A13 to A14…done
echo BIOS update A14 to A15…pending
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A14” && (
cls
ECHO Updating BIOS from A14 to A15rem %BIOS_v15%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…done
echo BIOS update A09 to A10…done
echo BIOS update A10 to A11…done
echo BIOS update A11 to A12…done
echo BIOS update A12 to A13…done
echo BIOS update A13 to A14…done
echo BIOS update A14 to A15…done
echo BIOS update A15 to A16…pending
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

wmic bios get SMBIOSBIOSVersion | find “A15” && (
cls
ECHO Updating BIOS from A15 to A16rem %BIOS_v16%
ping -n 6 127.0.0.1>nul
cls
echo BIOS update A02 to A03…done
echo BIOS update A03 to A04…done
echo BIOS update A04 to A05…done
echo BIOS update A05 to A06…done
echo BIOS update A06 to A07…done
echo BIOS update A07 to A08…done
echo BIOS update A08 to A09…done
echo BIOS update A09 to A10…done
echo BIOS update A10 to A11…done
echo BIOS update A11 to A12…done
echo BIOS update A12 to A13…done
echo BIOS update A13 to A14…done
echo BIOS update A14 to A15…done
echo BIOS update A15 to A16…done
echo.
Echo Restarting computer…
shutdown -r -f -t 0
ping -n 6 127.0.0.1>nul
)

cls
Echo All BIOS updates have been installed!
echo.
echo BIOS Version
wmic bios get SMBIOSBIOSVersion /value
pause
rem shutdown -r -f -t 0

Delete Printer via Command-line

email me

PrintUI.exe /dl /n “PrinterName” /q

Notes

printui.exe /if /b “<Name of Printer>” /f <Driver File> /u /r “<Address>” /m “<Name of Printer>”
Replace “<Name of Printer>” with the device’s product name, “<Driver File>” with the full file path linking to the INF file and “<Address>” with the method through which the printer communicates (e.g. “lpt1:” for the parallel port or “usb001” for USB).

 

References

http://blogs.technet.com/b/askperf/archive/2009/02/06/deploying-printers-and-print-drivers-remotely.aspx