Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. @echo off
  2.  
  3. title Computer Setup
  4.  
  5. :: BatchGotAdmin
  6. :-------------------------------------
  7. REM --> Check for permissions
  8. >nul 2>&1 "%SYSTEMROOT%system32cacls.exe" "%SYSTEMROOT%system32configsystem"
  9.  
  10. REM --> If error flag set, we do not have admin.
  11. if '%errorlevel%' NEQ '0' (
  12. echo Requesting administrative privileges...
  13. goto UACPrompt
  14. ) else ( goto gotAdmin )
  15.  
  16. :UACPrompt
  17. echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getadmin.vbs"
  18. echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%getadmin.vbs"
  19.  
  20. "%temp%getadmin.vbs"
  21. exit /B
  22.  
  23. :gotAdmin
  24. if exist "%temp%getadmin.vbs" ( del "%temp%getadmin.vbs" )
  25. pushd "%CD%"
  26. CD /D "%~dp0"
  27. :--------------------------------------
  28.  
  29. echo Computer Setup Command
  30. echo Version 3.0
  31. echo Date Created 7-7-17
  32. echo Author: Harley Frank
  33. echo ====================
  34.  
  35. ECHO Checking Registry for AutoRun Value
  36.  
  37. setlocal ENABLEEXTENSIONS
  38. set KEY_NAME="HKLMSoftwareMicrosoftWindows NTCurrentVersionRun"
  39. set VALUE_NAME=AutoRun
  40.  
  41. FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
  42. set ValueName=%%A
  43. set ValueType=%%B
  44. set ValueValue=%%C
  45. )
  46.  
  47. if defined ValueName (
  48. @echo Value Name = %ValueName%
  49. @echo Value Type = %ValueType%
  50. @echo Value Value = %ValueValue%
  51. set regValue=%ValueValue%
  52. ) else (
  53. @echo %KEY_NAME%%VALUE_NAME% not found.
  54. @echo Creating registry value now to begin the setup. This will take only but a moment.
  55. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 1
  56. )
  57.  
  58. Echo Now running the setup scripts. Please wait.
  59.  
  60.  
  61. if %regValue% EQU 1 (
  62.  
  63. echo Initial Restart Script
  64. echo Version 2
  65. echo Date Created 7-7-17
  66. echo Author: Harley Frank
  67. echo ====================
  68.  
  69. echo Restarting the Machine for the First Time.
  70.  
  71. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoAdminLogon /t REG_SZ /d 1
  72. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultUserName /t REG_SZ /d administrator
  73. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultPassword /t REG_SZ /d omitted
  74. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoLogonCount /t REG_DWORD /d 1
  75.  
  76. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 2
  77.  
  78. shutdown /r /c "Restarting computer to apply changes." /t 60 /f
  79.  
  80. ) else if %regValue% EQU 2 (
  81.  
  82. call "C:Source FilesScriptsrename.bat"
  83.  
  84. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 3
  85.  
  86. exit
  87.  
  88. ) else if %regValue% EQU 3 (
  89.  
  90. call "C:Source FilesScriptsdomain.bat"
  91.  
  92. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 4
  93.  
  94. exit
  95. ) else if %regValue% EQU 4 (
  96. echo running silent software install
  97.  
  98. "C:Source FilesSCCM2012Clientccmsetup.exe"
  99.  
  100. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionRun" /v AutoRun /t REG_SZ /d 5
  101.  
  102. msg "%username%" The machine setup should be completed now. SCCM should have successfully launched and is running in the background.
  103. ) else if %regValue% EQU 5 (
  104. rem del "C:ProgramDataMicrosoftWindowsStart MenuProgramsStartUprun.bat"
  105. echo DONE
  106. exit
  107. )
  108.  
  109. @ECHO OFF
  110.  
  111. title Computer Rename
  112.  
  113. SETLOCAL ENABLEDELAYEDEXPANSION
  114.  
  115. ECHO Setting Machine to Login as Administrator on next reboot.
  116.  
  117. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoAdminLogon /t REG_SZ /d 1
  118. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultUserName /t REG_SZ /d administrator
  119. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultPassword /t REG_SZ /d omitted
  120. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoLogonCount /t REG_DWORD /d 1
  121.  
  122. echo Rename Script
  123. echo Version 3.0
  124. echo Date Created 7-11-17
  125. echo Author: Harley Frank
  126. echo ====================
  127.  
  128. SET count=1
  129. SET /p campus= Please enter the abbreviation name of the campus you are at for this computer to be properly named:
  130.  
  131. FOR /F "tokens=* USEBACKQ" %%F IN (`wmic bios get serialnumber`) DO (
  132. SET serialnumber!count!=%%F
  133. SET /a count=!count!+1
  134. )
  135.  
  136. SET pcname=%campus%-%serialnumber2%
  137.  
  138. ::
  139. SET pcname=%pcname:~0,15%
  140. SET pcname=%pcname: =%
  141. ::
  142.  
  143. ECHO Automated Rename in Progress. Renaming to:
  144. ECHO %pcname%
  145.  
  146. WMIC computersystem where name="%computername%" call rename name="%pcname%"
  147.  
  148. shutdown /r /c "Restarting to apply computer name changes." /t 60 /f
  149.  
  150. @ECHO OFF
  151.  
  152. tile Domain Setup Script
  153.  
  154. echo Domain Setup Script
  155. echo Version 4.0
  156. echo Date Created 6-29-17
  157. echo Author: Harley Frank
  158. echo ====================
  159.  
  160. ECHO Prepping the machine to sign into the default domain account on restart.
  161.  
  162. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoAdminLogon /t REG_SZ /d 1
  163. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultDomainName /t REG_SZ /d omitted
  164. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultUserName /t REG_SZ /d adddomain
  165. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v DefaultPassword /t REG_SZ /d omitted
  166. ECHO y | reg add "HKLMSoftwareMicrosoftWindows NTCurrentVersionWinlogon" /v AutoLogonCount /t REG_DWORD /d 2
  167.  
  168. ECHO Adding the machine to the domain. Will restart when complete.
  169.  
  170. CALL PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:Source FilesScriptsdomain.ps1""' -Verb RunAs}"
  171.  
  172. ECHO Restarting machine now.
  173.  
  174. shutdown /r /c "Restarting to add the machine to the domain." /t 60 /f
  175.  
  176. Write-Output 'Domain Setup Script'
  177. Write-Output 'Version 4.0'
  178. Write-Output 'Date Created 6-29-17'
  179. Write-Output 'Author: Harley Frank'
  180. Write-Output '===================='
  181.  
  182. Write-Output 'Adding machine to the domain using adddomain user.'
  183.  
  184. $domain = "omitted"
  185. $password = "omitted" | ConvertTo-SecureString -asPlainText -Force
  186. $username = "$domainadddomain"
  187. $credential = New-Object System.Management.Automation.PSCredential($username,$password)
  188. Add-Computer -DomainName $domain -Credential $credential
  189.  
  190. Write-Output 'Restarting machine to apply changes.'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement