This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:windows:logon_script [2012/02/13 13:01] gcooper |
networking:windows:logon_script [2013/12/15 12:15] (current) gcooper |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Login Scripts ====== | ====== Login Scripts ====== | ||
+ | |||
+ | See also **[[networking: | ||
http:// | http:// | ||
Line 6: | Line 8: | ||
You would assign a Logon script on the " | You would assign a Logon script on the " | ||
+ | |||
+ | ===== Troubleshooting ===== | ||
+ | |||
+ | http:// | ||
+ | |||
+ | http:// | ||
+ | |||
+ | http:// | ||
===== Windows NT Method ===== | ===== Windows NT Method ===== | ||
Line 20: | Line 30: | ||
- Create or edit an existing Group Policy Object (GPO) | - Create or edit an existing Group Policy Object (GPO) | ||
- Right-click the GPO -> Edit | - Right-click the GPO -> Edit | ||
+ | |||
+ | **User Configuration -> Policies -> Windows Settings -> Scripts -> Logon -> Properties -> Add** | ||
**User Configuration -> Policies -> Windows Settings -> Scripts -> Logon -> Properties -> Show Files** | **User Configuration -> Policies -> Windows Settings -> Scripts -> Logon -> Properties -> Show Files** | ||
- | ===== Groups and IDs ===== | + | ===== Run Commands Based on Workstation OS ===== |
- | http:// | + | :!: This needs testing and updating. |
- | http:// | + | To execute commands based on the host OS, you can create an include |
- | + | ||
- | http:// | + | |
- | + | ||
- | ===== Sample Scripts ===== | + | |
- | + | ||
- | ==== Modular - VBS ==== | + | |
- | + | ||
- | {{ : | + | |
- | + | ||
- | http:// | + | |
- | + | ||
- | - Download and copy the logon.vbs file to the netlogon folder | + | |
- | - Create two additional folders in the same directory called ' | + | |
- | - Create a configuration file in the ' | + | |
- | - Using either the Windows NT method or the Group Policy method, call the login script specifying the config file: '' | + | |
- | - Use the detailed log files generated to troubleshoot and verify script execution. | + | |
- | + | ||
- | === Troubleshooting === | + | |
- | + | ||
- | **Start -> Run -> %temp%** | + | |
- | + | ||
- | * Look for logon_< | + | |
- | * If you don’t see the logfile here, then you know that the script did NOT run. | + | |
- | + | ||
- | === Sample global.conf === | + | |
< | < | ||
- | < | + | If instr(lcase(sOSCaption)," |
- | meta=1 | + | Call RunProcess(" |
- | drives=3 | + | ElseIf instr(lcase(sOSCaption)," |
- | printers=2 | + | Call RunProcess(" |
- | processes=4 | + | End If |
- | include=5 | + | </file> |
- | </order> | + | |
- | < | + | ===== Groups and IDs ===== |
- | description=For all users | + | |
- | created=02/12/12 | + | |
- | author=Gene Cooper | + | |
- | </ | + | |
- | < | + | http:// |
- | m:\\WIN2008R2-PDC\company|group: | + | |
- | t: | + | |
- | rem z: | + | |
- | </drives> | + | |
- | < | + | http:// |
- | \\WIN2008R2-PDC\pdfcreator; | + | |
- | rem \\server\hpprinter|group: | + | |
- | rem \\server\colorprinter|-group:domain users|group: | + | |
- | rem \\server\faxprinter|ip: | + | |
- | </ | + | |
- | < | + | http://ss64.com/nt/ |
- | rem c:\windows\write.exe | + | |
- | </processes> | + | |
- | < | + | ===== Sample Logon Scripts ===== |
- | rem File1.inc | + | |
- | rem File2.inc|computerOU: | + | |
- | rem File3.inc|group: | + | |
- | </ | + | |
- | </ | + | |
==== Lourdes - VBS ==== | ==== Lourdes - VBS ==== | ||
Line 253: | Line 219: | ||
End If | End If | ||
</ | </ | ||
+ | |||
+ | ==== Determine Workstation OS ==== | ||
+ | |||
+ | http:// | ||
+ | |||
+ | === Batch File Method 1 === | ||
+ | |||
+ | < | ||
+ | @ECHO off | ||
+ | SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION | ||
+ | |||
+ | FOR /f " | ||
+ | |||
+ | SET WVer=%%a | ||
+ | SET WVer=!WVer: | ||
+ | SET WVer=!WVer!.%%b.%%c | ||
+ | SET WVer=!WVer: | ||
+ | ) | ||
+ | |||
+ | IF DEFINED ProgramFiles(x86) ( | ||
+ | SET OSBit=x64 | ||
+ | ) ELSE ( | ||
+ | SET OSBit=x86 | ||
+ | ) | ||
+ | |||
+ | ECHO %WVer% %OSBit% | ||
+ | </ | ||
+ | |||
+ | === Batch File Method 2 === | ||
+ | |||
+ | < | ||
+ | @ECHO OFF | ||
+ | :: **************************************** | ||
+ | :: My Login Script Title - Change Me | ||
+ | :: *************************************** | ||
+ | |||
+ | :: ------ | ||
+ | SET WINVER=NotSupported | ||
+ | SET errMsg1= | ||
+ | SET netlogon=\\xxx\netlogon | ||
+ | TITLE Logon Script File at xxxxx | ||
+ | |||
+ | :: ------ OS analyze | ||
+ | if %OS%==Windows_NT goto setOS | ||
+ | GOTO error | ||
+ | |||
+ | :setOS | ||
+ | VER | FIND " | ||
+ | VER | FIND " | ||
+ | VER | FIND " | ||
+ | VER | FIND " | ||
+ | IF " | ||
+ | |||
+ | :perUser | ||
+ | IF %USERNAME%==xxxx GOTO testArea | ||
+ | |||
+ | :perOS | ||
+ | :: ------ | ||
+ | IF %WINVER%==W2K ( | ||
+ | CALL %netlogon%\mapdrives.bat | ||
+ | CALL %netlogon%\log.bat | ||
+ | GOTO beforeEnd | ||
+ | ) | ||
+ | :: ------ | ||
+ | IF %WINVER%==WXP ( | ||
+ | CALL %netlogon%\mapdrives.bat | ||
+ | CALL %netlogon%\log.bat | ||
+ | GOTO beforeEnd | ||
+ | ) | ||
+ | :: ------ | ||
+ | IF %WINVER%==WVista ( | ||
+ | CALL %netlogon%\mapdrives.bat | ||
+ | CALL %netlogon%\log.bat | ||
+ | GOTO beforeEnd | ||
+ | ) | ||
+ | :: ------ | ||
+ | IF %WINVER%==W7 ( | ||
+ | CALL %netlogon%\mapdrives.bat | ||
+ | CALL %netlogon%\log.bat | ||
+ | GOTO beforeEnd | ||
+ | ) | ||
+ | GOTO beforeEnd | ||
+ | |||
+ | :testArea | ||
+ | CALL %netlogon%\mapdrives_test.bat | ||
+ | CALL %netlogon%\log.bat | ||
+ | GOTO beforeEnd | ||
+ | |||
+ | :error | ||
+ | |||
+ | :beforeEnd | ||
+ | |||
+ | :end | ||
+ | </ | ||
+ | |||
+ | ===== Printers ===== | ||
+ | |||
+ | This will allow regular (unprivileged) users to add printers from your print server. | ||
+ | |||
+ | In Group Policy: | ||
+ | |||
+ | **Computer Configuration -> Administrative Templates -> Printers -> Point and Print Restrictions** | ||
+ | |||
+ | - Set it to " | ||
+ | - Put a check box in "Users can only point and print to these servers:" | ||
+ | - Enter your print server name in the box " | ||
+ | - Set both Security Prompts to "Do not show" |