echo off
cls
:: This batch file will rename the computer using the service tag in BIOS.
:: find out what path the batch file is in
:: set batch_path=%~dp0
:: change drive
:: %batch_path:~0,2%
:: crop the last character and cd into it
:: cd %batch_path:~0,-1%
:: clear screen show bitlocker status
:: cls
:: WMIC computersystem where caption=’current_pc_name’ rename new_pc_name
:: pipe machine service tag to serial.txt so that later we can reverse pipe into the variable that used to name the capture file
wmic bios get serialnumber | find /v “SerialNumber” > %temp%/serial.txt
::pipe in serial
set /p serial=<%temp%\serial.txt
:: trim spaces
set serial_temp=%serial: =%
:: store serial
set serial=%serial_temp%
set current_name=%hostname%
@echo.
@echo *************************************************************************************
@echo — Renaming machine from %computername% to XXXXX%serial% —
@echo *************************************************************************************
wmic computersystem where “name=’%computername%'” call rename name=XXXXX%serial%
echo off
cls
::
:: This needs to run as admin for bitlocker to report status.
::
:: This batch file will create an informative capture of a bitlocker status once complete encryption using cap.exe dos screen capture.
::find out what path the batch file is in
set batch_path=%~dp0
::change drive
%batch_path:~0,2%
::crop the last character and cd into it
cd %batch_path:~0,-1%
::we loop until bitlocker task is 100%
echo Waiting for Bitlocker Encrytion to be 100%
:loop
::repeat until find 100%
timeout 1 > nul
echo .
manage-bde c: -status | find “100%”
if errorlevel 1 goto loop
::bitlocker done
:: clear screen show bitlocker status
cls
manage-bde c: -status
:: display information on build
echo Enginner: %HomePath%
echo Machine name: %ComputerName%
::pipe machine service tag to serial.txt so that later we can reverse pipe into the variable that used to name the capture file
wmic bios get serialnumber | find /v “SerialNumber” > %temp%/serial.txt
::pipe in serial
set /p serial=<%temp%\serial.txt
:: trim spaces
set serial_temp=%serial: =%
:: store serial
set serial=%serial_temp%
::pipe machine asset tag to asset.txt so that later we can reverse pipe into the variable that used to name the capture file
wmic systemenclosure get SMBIOSAssetTag | find /v “SMBIOSAssetTag” > %temp%/asset.txt
::pipe in asset tag
set /p asset=<%temp%\asset.txt
:: trim spaces
set asset_temp=%asset: =%
:: store asset tag
set asset=%asset_temp%
:: display system info
echo Service Tag: %serial% – Asset Tag: – %asset%
echo Users directories present:
dir c:\Users\ /b
echo Capture taken on %date%
:: capture the screen, set to 1080p
cap “Bitlocker – Service Tag %serial% – Machine %ComputerName% – Asset Tag %asset%.jpg” 0 0 1920 1080
:: create an export of all software install, diagnostic
::echo Exporting software list to “Machine %ComputerName% – Service Tag %serial% – Asset Tag %asset%.txt”
::wmic product get name, version, vendor > “Machine %ComputerName% – Service Tag %serial% – Asset Tag %asset%.txt”
@echo off
cls
:: if the batch file is not run as admin, quit
net.exe session 1>NUL 2>NUL || (Echo This script requires admin elevated rights, exiting. & echo. & pause & Exit /b 1)
echo This script will perform the following tasks:
echo.
echo – copy new group policy files to enable bitlocker pin requirement
echo – reload the policy
echo – trigger bitlocker encryption
echo – type in the bitlocker pin 8 digits, you will not see your input, verify pin.
echo – forced reboot in 5 secs (give time for encrytion to
echo – on reboot encryption will enable, login and monitor status by clicking on key is desktray.
echo.
::find out what path the batch file is in
set batch_path=%~dp0
::crop the last character and cd into it
cd %batch_path:~0,-1%
:: change drive
cd %CD%
echo This batch file is being run from %batch_path%
echo.
xcopy GroupPolicy\. c:\windows\system32\GroupPolicy\ /s/e/y
gpupdate /force
::manage-bde -on C: -RecoveryKey D: -RecoveryPassword
manage-bde -protectors -add c: -pw
manage-bde -on -usedspaceonly C:
shutdown /r -t 5
net session >nul 2>&1 || exit
This script runs the net session command, which returns an error message if the user is not an administrator. The || operator allows the script to execute the exit command if the previous command returns an error code. The >nul 2>&1 redirects the output of the net session command to null so that it doesn’t display any error messages on the screen.
Get path
set batch_path=%~dp0
cd into it, remove last character
cd %batch_path:~0,-1%
change drive from a batch file that has been elevated
%~d0%
net.exe session 1>NUL 2>NUL || (Echo This script requires admin elevated rights, exiting. & echo. & pause & Exit /b 1)