Tag Archives: cmd
Rename machine name in DOS

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%

Posted on March 25, 2023, 11:35 am By
Categories: tech tips Tags:
Capture service tag, assset tag of Dell systems and more

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”

 

Posted on March 25, 2023, 11:28 am By
Categories: tech tips Tags: ,
Active bitlocker using PIN with DOS

@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

Posted on March 25, 2023, 11:18 am By
Categories: tech tips Tags:
Here is a one-line batch script in MS-DOS command to check the elevated status and exit the script if the user is not an administrator.

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.

Posted on February 4, 2023, 7:47 pm By
Categories: tech tips Tags: ,
Find out what path a batch has been executed from

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%

 

Posted on January 28, 2023, 8:02 pm By
Categories: tech tips Tags:
Command line to check if you admin rights and exit if not

net.exe session 1>NUL 2>NUL || (Echo This script requires admin elevated rights, exiting. & echo. & pause & Exit /b 1)

 

Posted on January 28, 2023, 7:51 pm By
Categories: tech tips Tags: