(-)
(-)
Line 9: Line 9:
*set the password of administrator account
*set the password of administrator account
This script is used (and may be very useful to) to automate school laboratories configuration.
This script is used (and may be very useful to) to automate school laboratories configuration.
 +
Note: rev.01 - add some "wmic useraccount" commands to lock password expiration
'''setup.bat'''
'''setup.bat'''
Line 27: Line 28:
echo "Make user: %%x"
echo "Make user: %%x"
net user %%x /passwordreq:no /active:yes /comment:"Class %%x" /expires:never /fullname:"Class %%x" /passwordchg:no /homedir:D:\Users\%%x /add
net user %%x /passwordreq:no /active:yes /comment:"Class %%x" /expires:never /fullname:"Class %%x" /passwordchg:no /homedir:D:\Users\%%x /add
 +
wmic useraccount where "name='%%x'" set PasswordExpires=FALSE
 +
wmic useraccount where "name='%%x'" set disabled=FALSE
)
)

Revision as of 11:26, 17 April 2014

Here is a simple .bat script that:

This script is used (and may be very useful to) to automate school laboratories configuration. Note: rev.01 - add some "wmic useraccount" commands to lock password expiration

setup.bat

echo off
if  "%1" == "" (
echo "Usage: %0 N_PC_to_configure" 
exit /b
)
 
echo "Set user profile to D:\Users"
mkdir d:\Users
icacls "D:\Users" /grant everyone:(OI)(CI)F
reg add  "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v ProfilesDirectory /t REG_EXPAND_SZ /d "D:\Users" /f
 
echo "Make Classes/Students accounts"
for %%x in (1A 1B 2A 2B ... 3A 4A 5A) do (
echo "Make user: %%x"
net user %%x /passwordreq:no /active:yes /comment:"Class %%x" /expires:never /fullname:"Class %%x" /passwordchg:no /homedir:D:\Users\%%x /add
wmic useraccount where "name='%%x'" set PasswordExpires=FALSE
wmic useraccount where "name='%%x'" set disabled=FALSE
)
 
echo "Make Teachers protected accounts"
net user Teacher1 pwteacher1 /passwordreq:yes /active:yes /expires:never /fullname:"Teacher 1" /passwordchg:yes /homedir:D:\Users\teacher1 /add
net user Teacher2 pwteacher2 /passwordreq:yes /active:yes /expires:never /fullname:"Teacher 2" /passwordchg:yes /homedir:D:\Users\teacher2 /add
net user Teacher3 pwteacher3 /passwordreq:yes /active:yes /expires:never /fullname:"Teacher 3" /passwordchg:yes /homedir:D:\Users\teacher3 /add
 
echo "Set IP to %1"
netsh interface ip set address "Local Area Connection" static 192.168.0.%1 255.255.255.0 192.168.0.254 1
 
echo "Set DNS"
netsh interface ip add dns name="Local Area Connection" addr=8.8.8.8 index=1
netsh interface ip add dns name="Local Area Connection" addr=8.8.4.4 index=2
 
echo "Rename Hostname to LPE-PC-%1"
wmic computersystem where name="Master-PC" call rename name="LPE-PC-%1"
 
echo "Set Master password (Master is an administrator)"
net user Master abcd1234

Tested on Windows 7 Professional 32 bit. Use at own risk!

Retrieved from "http://www.zoros.org/wiki/index.php?title=A_simple_script_that_creates_multiple_Windows_user_accounts,_puts_home_directories_to_drive_D:,_rename_the_hostname_and_configure_LAN,_automatically."