Tag Archives: cmd
Dell command update via DOS, check if Crowdstrike or any program is installed via CMD, example.

:: //*************************************************************************************************
:: //
:: // Post – Automated installation of all post-build software.
:: //
:: // For Kantar by Juan Calderon
:: //
:: // Date: 11/10/2021
:: //
:: // Latest Update: 18/05/2021 — Changelog as follows:
:: // 1. No changes
:: //
:: //*************************************************************************************************

@echo off

@echo.
@echo *************************************************************************************
@echo — Remove c:\EnableBL —
@echo *************************************************************************************

rd c:\EnableBL /s /q

c:
cd C:\post

@echo.
@echo *************************************************************************************
@echo — Install CERT —
@echo *************************************************************************************

certutil.exe -addstore root netd2.cer

@echo.
@echo *************************************************************************************
@echo — Install regedits that stimulate BigFix —
@echo *************************************************************************************

::net stop besclient
::@echo Importing new BigFix client resource settings
::regedit /s “\bigfix\cpu_bind_config.reg”
::net start besclient

@echo.
@echo *************************************************************************************
@echo — Remove Forcepoint —
@echo *************************************************************************************
cscript remove_forcepoint.vbs

timeout 15

@echo.
@echo *************************************************************************************
@echo — Install Dell Power Manager —
@echo *************************************************************************************
MSIEXEC /i C:\post\DPM_Setup64_3_11_0.msi /qn

timeout 15

@echo.
@echo *************************************************************************************
@echo — Install Displaylink —
@echo *************************************************************************************

call “C:\post\DisplayLink_USB_Graphics_Software_for_Windows10.2 M4-EXE.exe” -silent

@echo.
@echo *************************************************************************************
@echo — Checking if CrowdStrike installed… —
@echo *************************************************************************************
wmic product get name, version, vendor | find “CrowdStrike”
IF %ERRORLEVEL% NEQ 1 (
@echo CrowdStrike check complete – found.
)
IF %ERRORLEVEL% NEQ 0 (
color 4
@echo CrowdStrike check complete – NOT FOUND.
@echo Installing it …
start c:\post\CrowdStrike\WindowsSensor.exe /install /quiet /norestart CID=03dec07bdbd24b1584d0b36e7000b2a2-9e
timeout 10

)

::call c:\post\!machine_name_rename.bat

@echo.
@echo *************************************************************************************
@echo — Install Dell Command Update, Firmware, Driver updates —
@echo *************************************************************************************
@echo Installing Dell Command Update
call “c:\post\DellCommandUpdate\Dell-Command-Update-Application_T97XP_WIN_4.6.0_A00.EXE” /S

timeout 15
@echo.
@echo.
@echo Checking for and installing firmware updates and drivers
@echo.
@echo Scanning for Updates
call “C:\Program Files (x86)\Dell\CommandUpdate\dcu-cli.exe” /scan -silent
@echo.
@echo Installing updates
call “C:\Program Files (x86)\Dell\CommandUpdate\dcu-cli.exe” /applyUpdates -silent -reboot=enable
@echo.
@echo Installing drivers
call “C:\Program Files (x86)\Dell\CommandUpdate\dcu-cli.exe” /driverInstall -silent -reboot=enable

 

@echo.
@echo *************************************************************************************
@echo — Finished, reset and manually check Dell Command update again, more Dell todo —
@echo *************************************************************************************

pause

shutdown /r -t 1

 

Posted on March 25, 2023, 2:21 pm By
Categories: tech tips Tags:
Rename machine name in DOS

echo off
cls
:: by Juan Calderon 09/22
::
:: Developed as an alternative over the manual computer naming of XXXXXX[service tag]
::
:: This batch file will rename the computer using the servivce 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
:: by Juan Calderon 04/22
::
:: This needs to run as admin for bitlocker to report status.
::
:: Developed as an alternative over the snipping tool
::
:: 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
:: Written by Juan Calderon 22/1/23
::
:: Purpose: To encrypt after MDT built to decommission.
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:
Power settings in DOS

:: 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)

::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 – special way to get vairable in admin mode
echo %~d0%
%~d0%

xcopy GroupPolicy\. c:\windows\system32\GroupPolicy\ /s/e/y

pause

::pause
:: edit power plan settings

::on mains
powercfg /change monitor-timeout-ac 240
::on battery
powercfg /change monitor-timeout-dc 120

::on mains
powercfg /change standby-timeout-ac 0
::on battery
powercfg /change standby-timeout-dc 240

 

 

::——CHANGE LID SETTINGS
::https://learn.microsoft.com/en-us/windows-hardware/customize/power-settings/power-button-and-lid-settings
::https://www.elevenforum.com/t/change-power-button-action-in-windows-11.5186/

::power button

::AC on mains 3 SHUTDOWN
powercfg -setacvalueindex SCHEME_CURRENT 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 3
powercfg -SetActive SCHEME_CURRENT

::DC on battery 3 SHUTDOWN
powercfg -setdcvalueindex SCHEME_CURRENT 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 3
powercfg -SetActive SCHEME_CURRENT

::sleep button
::https://www.tenforums.com/tutorials/107766-add-remove-sleep-button-action-power-options-windows.html
::https://github.com/LinkPhoenix/Windows-10-IoT-Enterprise-Optimization/blob/master/Config%20Power%20Options%20(High%20performance).bat
::https://www.elevenforum.com/t/change-sleep-button-action-in-windows-11.5198/

::DC power battery 2 hibernate
powercfg -setdcvalueindex SCHEME_CURRENT 4f971e89-eebd-4455-a8de-9e59040e7347 96996bc0-ad50-47ec-923b-6f41874dd9eb 2

::AC power mains 2 hibernate
powercfg -setacvalueindex SCHEME_CURRENT 4f971e89-eebd-4455-a8de-9e59040e7347 96996bc0-ad50-47ec-923b-6f41874dd9eb 2

::powercfg -SetActive SCHEME_CURRENT

:: REG ADD “HKLM\Software\Policies\Microsoft\Power\PowerSettings\96996BC0-AD50-47EC-923B-6F41874DD9EB” /v “DCSettingIndex” /t “REG_DWORD” /d “2” /f
:: REG ADD “HKLM\Software\Policies\Microsoft\Power\PowerSettings\96996BC0-AD50-47EC-923B-6F41874DD9EB” /v “ACSettingIndex” /t “REG_DWORD” /d “2” /f

::CLOSE LID
::AC power battery 3 DO NOTHING
::powercfg -setdcvalueindex SCHEME_CURRENT 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0
::powercfg -SetActive SCHEME_CURRENT

::DC power mains 3 DO NOTHING
::powercfg -setacvalueindex SCHEME_CURRENT 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0
::powercfg -SetActive SCHEME_CURRENT

::AC on mains
powercfg /setACvalueIndex scheme_current sub_buttons lidAction 0
::DC on battery
powercfg /setDCvalueIndex scheme_current sub_buttons lidAction 0

::—- EDIT LID SETTINGS
:: TICK BOXES
::reg import “E:\admin\Fast Startup is turned off.reg”

REG ADD “HKLM\SYSTEM\ControlSet001\Control\Session Manager\Power” /v “HiberbootEnabled” /t “REG_DWORD” /d “00000000” /f

::reg import “E:\admin\Hibernate on menu.reg”
REG ADD “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings” /v “ShowHibernateOption” /t “REG_DWORD” /d “00000001” /f

powercfg.exe /hibernate on
pause

 

Posted on March 25, 2023, 11:06 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: