Skip to content

Instantly share code, notes, and snippets.

@ruzickap ruzickap/win7-user.bat
Last active Dec 27, 2015

Embed
What would you like to do?
win7 customization file. Run right after you first log in with administrator rights.
:: Tested on Windows 7
echo on
rem for /f "tokens=3" %%i in ('netsh interface ip show addresses "Local Area Connection" ^|findstr IP.Address') do set IP=%%i
rem for /f "tokens=2 delims=. " %%j in ('nslookup %IP% ^|find "Name:"') do set HOSTNAME=%%j
@echo.
@echo Enable Administrator
net user administrator /active:yes
@echo.
@echo Change password and Password Complexity to allow simple passwords
net accounts /maxpwage:unlimited
net accounts /minpwlen:0
secedit /export /cfg c:\password.cfg
powershell -command "${c:\password.cfg}=${c:\password.cfg} | %% {$_.Replace('PasswordComplexity = 1', 'PasswordComplexity = 0')}"
secedit /configure /db %windir%\security\new.sdb /cfg c:\password.cfg /areas SECURITYPOLICY
del c:\password.cfg
net user Administrator xxxx
@echo.
@echo Autologin
rem reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d "1" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d "Administrator" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d "xxxx" /f
@echo.
@echo Enable Remote Desktop
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
@echo.
@echo Set proxy settings
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v MigrateProxy /t REG_DWORD /d 0x1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d "http=proxy.example.com:3128;https=proxy.example.com:3128;ftp=proxy.example.com:3128;socks=proxy.example.com:3128;" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d ^<local^>; /f
reg add "HKLM\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxySettingsPerUser /t REG_DWORD /d 0x0 /f
@echo.
@echo Creating bat script running on start to check if the proxy server is available or not.
echo @echo off ^
ping -n 3 proxy.example.com ^
if %%ERRORLEVEL%% EQU 0 ( ^
@echo. ^
@echo *** Setting proxy ^
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0x1 /f ^
) else ( ^
@echo. ^
@echo *** Proxy disabled ^
) ^
> "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup\proxy.bat"
start /MIN "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup\proxy.bat"
@echo.
@echo Configure NTP server
w32tm /config /manualpeerlist:"ntp.cesnet.cz" /reliable:yes /update
net start w32time
rem w32tm /resync /rediscover
rem w32tm /query /peers
rem w32tm /query /status
@echo.
@echo Disable firewall
netsh advfirewall set allprofiles state off
@echo.
@echo Change TimeZone
tzutil /s "Central Europe Standard Time"
@echo.
@echo Disable IPv6
reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 255
@echo.
@echo Disable firewall
netsh advfirewall set allprofiles state off
rem @echo.
rem @echo Server name change
rem powershell -command "$sysInfo = Get-WmiObject -Class Win32_ComputerSystem; $sysInfo.Rename('%HOSTNAME%');"
@echo.
@echo Run IE to get proxy settings working properly (workaround for proxy settings)
start /d "%PROGRAMFILES%\Internet Explorer" iexplore.exe www.google.com
@echo.
@echo Disable Windows Update
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUState /t REG_DWORD /d 7 /f
ping -n 3 127.0.0.1 > nul
shutdown /r /t 0
move c:\win7-user.bat c:\windows\temp\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.