Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- title Computer Setup
- :: BatchGotAdmin
- :-------------------------------------
- REM --> Check for permissions
- >nul 2>&1 "%SYSTEMROOT%system32cacls.exe" "%SYSTEMROOT%system32configsystem"
- REM --> If error flag set, we do not have admin.
- if '%errorlevel%' NEQ '0' (
- echo Requesting administrative privileges...
- goto UACPrompt
- ) else ( goto gotAdmin )
- :UACPrompt
- echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getadmin.vbs"
- echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%getadmin.vbs"
- "%temp%getadmin.vbs"
- exit /B
- :gotAdmin
- if exist "%temp%getadmin.vbs" ( del "%temp%getadmin.vbs" )
- pushd "%CD%"
- CD /D "%~dp0"
- :--------------------------------------
- echo Computer Setup Command
- echo Version 3.0
- echo Date Created 7-7-17
- echo Author: Harley Frank
- echo ====================
- ECHO Checking Registry for AutoRun Value
- setlocal ENABLEEXTENSIONS
- set KEY_NAME="HKLMSoftwareMicrosoftWindows NTCurrentVersionRun"
- set VALUE_NAME=AutoRun
- FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
- set ValueName=%%A
- set ValueType=%%B
- set ValueValue=%%C
- )
- if defined ValueName (
- @echo Value Name = %ValueName%
- @echo Value Type = %ValueType%
- @echo Value Value = %ValueValue%
- set regValue=%ValueValue%
- ) else (
- @echo %KEY_NAME%%VALUE_NAME% not found.
- @echo Creating registry value now to begin the setup. This will take only but a moment.
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 1
- )
- Echo Now running the setup scripts. Please wait.
- if %regValue% EQU 1 (
- echo Initial Restart Script
- echo Version 2
- echo Date Created 7-7-17
- echo Author: Harley Frank
- echo ====================
- echo Restarting the Machine for the First Time.
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoAdminLogon /t REG_SZ /d 1
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultUserName /t REG_SZ /d administrator
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultPassword /t REG_SZ /d omitted
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoLogonCount /t REG_DWORD /d 1
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 2
- shutdown /r /c "Restarting computer to apply changes." /t 60 /f
- ) else if %regValue% EQU 2 (
- call "C:Source FilesScriptsrename.bat"
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 3
- exit
- ) else if %regValue% EQU 3 (
- call "C:Source FilesScriptsdomain.bat"
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 4
- exit
- ) else if %regValue% EQU 4 (
- echo running silent software install
- "C:Source FilesSCCM2012Clientccmsetup.exe"
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 5
- msg "%username%" The machine setup should be completed now. SCCM should have successfully launched and is running in the background.
- ) else if %regValue% EQU 5 (
- rem del "C:ProgramDataMicrosoftWindowsStart MenuProgramsStartUprun.bat"
- echo DONE
- exit
- )
- @ECHO OFF
- title Computer Rename
- SETLOCAL ENABLEDELAYEDEXPANSION
- ECHO Setting Machine to Login as Administrator on next reboot.
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoAdminLogon /t REG_SZ /d 1
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultUserName /t REG_SZ /d administrator
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultPassword /t REG_SZ /d omitted
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoLogonCount /t REG_DWORD /d 1
- echo Rename Script
- echo Version 3.0
- echo Date Created 7-11-17
- echo Author: Harley Frank
- echo ====================
- SET count=1
- SET /p campus= Please enter the abbreviation name of the campus you are at for this computer to be properly named:
- FOR /F "tokens=* USEBACKQ" %%F IN (`wmic bios get serialnumber`) DO (
- SET serialnumber!count!=%%F
- SET /a count=!count!+1
- )
- SET pcname=%campus%-%serialnumber2%
- ::
- SET pcname=%pcname:~0,15%
- SET pcname=%pcname: =%
- ::
- ECHO Automated Rename in Progress. Renaming to:
- ECHO %pcname%
- WMIC computersystem where name="%computername%" call rename name="%pcname%"
- shutdown /r /c "Restarting to apply computer name changes." /t 60 /f
- @ECHO OFF
- tile Domain Setup Script
- echo Domain Setup Script
- echo Version 4.0
- echo Date Created 6-29-17
- echo Author: Harley Frank
- echo ====================
- ECHO Prepping the machine to sign into the default domain account on restart.
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoAdminLogon /t REG_SZ /d 1
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultDomainName /t REG_SZ /d omitted
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultUserName /t REG_SZ /d adddomain
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultPassword /t REG_SZ /d omitted
- ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoLogonCount /t REG_DWORD /d 2
- ECHO Adding the machine to the domain. Will restart when complete.
- CALL PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:Source FilesScriptsdomain.ps1""' -Verb RunAs}"
- ECHO Restarting machine now.
- shutdown /r /c "Restarting to add the machine to the domain." /t 60 /f
- Write-Output 'Domain Setup Script'
- Write-Output 'Version 4.0'
- Write-Output 'Date Created 6-29-17'
- Write-Output 'Author: Harley Frank'
- Write-Output '===================='
- Write-Output 'Adding machine to the domain using adddomain user.'
- $domain = "omitted"
- $password = "omitted" | ConvertTo-SecureString -asPlainText -Force
- $username = "$domainadddomain"
- $credential = New-Object System.Management.Automation.PSCredential($username,$password)
- Add-Computer -DomainName $domain -Credential $credential
- Write-Output 'Restarting machine to apply changes.'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement