> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > On Behalf Of Christopher Perry > Sent: Thursday, June 19, 2008 7:14 AM > To: [email protected] > Subject: [Samba] login scripts --what to use > > Hi, > We're setting up a PDC, and would like to have a login script > to deliver the mapped drives to users in particular groups, > and connect to printers. The printer drivers come from the > [print$], share. > > Does anyone have any good resources for this? What's the > easiest and simplest thing to get going --vbscript or batch files? > > Thanks, > chris
I use bat files, because I'm not smart enough to figure out vbscript..... I'm posting this because I get a lot of help here, but rarely can help anyone. I am better at windows than *nix, but I'm trying to learn... There is MORE here than you asked for, but maybe someone else can use something. Please, don't tease..... Here's my logon script which calls a bunch of others. ---------------------------------------------------------------------------- ---------------------------------------------- logon.bat: @echo on set logondrive=\\server\netlogon\scripts set software=p:\software set logs=\\server\logs :start ECHO Login - %username% - %date% - %time% >> "%logs%\%computername%.txt" CALL %logondrive%\drives.bat CALL %logondrive%\O2K7fmt.bat CALL %logondrive%\pfbk.bat CALL %logondrive%\dns.bat CALL %logondrive%\filecopy.bat CALL %logondrive%\favorites.bat CALL %logondrive%\flash9.bat CALL %logondrive%\java.bat CALL %logondrive%\ar707.bat CALL %logondrive%\svg.bat CALL %logondrive%\ldap.bat Call %software%\mozilla\firefox\ffxupdate.bat CALL %logondrive%\stats.bat CALL %logondrive%\wsusupdate.bat cscript p:\printers.vbs :EOF ---------------------------------------------------------------------------- ---------------------------------------------- The "%logs% folder is writeable, but not readable. You can look at the folder (if you knew where), but it appears there is nothing in there. Only root can look at the files in there... There was a series of posts earlier this year on how to make one. ( http://lists.samba.org/archive/samba/2008-April/139726.html ) I think that's the pertinent post. Drives.bat maps drives. O2K7fmt installs the Office 2007 file format converters... Pfbk.bat installs Microsoft's pst backup utility for Outlook. Dns.bat sets the DNS servers (From before we had DCHP set up) really can REM it out now.... Filecopy.bat does just that, plus does registry imports.... Favorites.bat copies a folder of important favorites to the users favorites folder. (I can go the other way to and collect everyones favorites.....It gets interesting sometimes....) Fast.bat robocopy's a network folder to a local folder for my parts department machines to run their parts catalog local. Flash9 install's flash9.... Java install's java 1.4 (version required for DMS.) LDAP.bat imports a prf file to set the ldap server for Outlook to use to resolve email addresses. (I'm not currently using LDAP for anything else. Kind of waiting on Samba 4....) AR707 installs Acrobat reader 7.07. (version required for DMS.) Svg.bat installs Adobe SVG reader. (required by service department program for looking at wiring diagrams.) Ffxupdate installs/updates firefox. For Sales Department, but I just let it install on all. Printers.vbs installs a certain printer. I really need to figure this out better. Stats.bat writes some machine information to a file. Wsusupdate sets the machine to get it's updates from my WSUS server. (it recently died, so I had to point them to the new server.) Some of these were written before I learned some things, so they are not all consistent. Setting and using the variables, for instance..... You could just use the logon.bat and drives.bat example to get the drives mapped. I need to work on my printers..... Here's the rest... (ifmember and robocopy from the W2K3 server resource kit) http://www.microsoft.com/DOWNLOADS/details.aspx?familyid=9D467A69-57FF-4AE7- 96EE-B18C4790CFFD&displaylang=en ---------------------------------------------------------------------------- ---------------------------------------------- Drives.bat: @ECHO ON net time \\server /set /yes net use h: \\server\%username% /persistent:yes \\server\netlogon\ifmember "dominname\client" if not errorlevel 1 goto accts net use i: \\server\client :accts \\server\netlogon\ifmember "dominname\acctsdep" if not errorlevel 1 goto parts net use j: \\server\accounts :parts \\server\netlogon\ifmember "dominname\partsdept" if not errorlevel 1 goto service net use k: \\server\parts :service \\server\netlogon\ifmember "dominname\servicedept" if not errorlevel 1 goto sales net use s: \\server\service :sales \\server\netlogon\ifmember "dominname\salesdept" if not errorlevel 1 goto internet net use l: \\server\sales :internet \\server\netlogon\ifmember "dominname\internet" if not errorlevel 1 goto hr net use s: \\server\internet :hr \\server\netlogon\ifmember "dominname\hr" if not errorlevel 1 goto finance net use m: \\server\hr :finance \\server\netlogon\ifmember "dominname\finsrvcs" if not errorlevel 1 goto managers net use n: \\server\finance :managers \\server\netlogon\ifmember "dominname\Managers" if not errorlevel 1 goto public net use o: \\server\managers :public net use p: \\server\public /persistent:yes :EOF ---------------------------------------------------------------------------- ---------------------------------------------- O2K7fmt.bat: @ECHO ON if exist "%systemdrive%\Program Files\Microsoft Office\Office12\excelcnv.exe" GOTO EOF "%software%\office07compat\fileformatconverters.exe" /passive /quiet /norestart :EOF ---------------------------------------------------------------------------- ---------------------------------------------- pfbk.bat: if EXIST "%systemdrive%\program files\microsoft office\office11\addins\outbak.dll" GOTO EOF :install start /wait %software%\pstbackup\pfbackup.exe /q :EOF ECHO "SKIPPED" ---------------------------------------------------------------------------- ---------------------------------------------- DNS.bat (was setting it manually using "set dns "Local Area Connection" xxx.xxx.xxx.xxx" and "add dns "Local Area Connection" xxx.xxx.xxx.xxx index=2") but now: @echo ON REM netsh interface ip set dns "Local Area Connection" dhcp ---------------------------------------------------------------------------- ---------------------------------------------- Filecopy.bat: @ECHO on xcopy %logondrive%\scripts "%systemroot%\system32\GroupPolicy\user\scripts\" /s /e /I /v /c /y >NUL xcopy %logondrive%\scripts\logon\logon.bat %systemdrive%\egn\ /I /y >NUL xcopy %logondrive%\robocopy.exe %systemroot%\system32\ /Y >NUL xcopy %logondrive%\hosts %systemroot%\system32\drivers\etc /Y >NUL xcopy %logondrive%\lmhosts %systemroot%\system32\drivers\etc /Y >NUL xcopy "p:\templates" "%userprofile%\Application Data\Microsoft\Templates" /I /c /y >NUL REM regedit.exe /s %logondrive%\logonmessage.reg regedit.exe /s %logondrive%\wsus.reg regedit.exe /s %logondrive%\nosearch.reg regedit.exe /s %logondrive%\sharedoc.reg regedit.exe /s %logondrive%\defaultzone.reg regedit.exe /s %logondrive%\zones.reg regedit.exe /s %logondrive%\profile.reg :EOF ---------------------------------------------------------------------------- ---------------------------------------------- Favorites.bat: (need to change this to use the variables...) @ECHO on xcopy "%logondrive%\favorites\*.*" "%userprofile%\favorites\" /y >NUL :EOF ---------------------------------------------------------------------------- ---------------------------------------------- FLASH9.bat: (really old, need to re-look at. Stop using check file to determine if it needs to run.) @Echo on GOTO IE :IE IF EXIST "%systemdrive%\EGN\checks\flash9.chk" GOTO ffx msiexec /i %software%\Adobe\flash9.msi /q ECHO %TIME% - %DATE% >> "%systemdrive%\EGN\checks\flash9.chk" REM ECHO flashinstall - %TIME% - %DATE% >> "%logs%\%computername%.txt" :ffx if EXIST "%systemdrive%\egn\checks\ffxflash9.chk" GOTO EOF if NOT EXIST "%programfiles%\mozilla firefox\firefox.exe" GOTO EOF %software%\Adobe\flash9firefox.exe /silent ECHO %TIME% - %DATE% >> "%systemdrive%\EGN\checks\ffxflash9.chk" REM ECHO ffxflashinstall - %TIME% - %DATE% >> "%logs%\%computername%.txt" :EOF ---------------------------------------------------------------------------- ---------------------------------------------- Ldap.bat: (need to stop using check files....) @Echo on if EXIST "%systemdrive%\egn\checks\ldap.chk" GOTO EOF if NOT EXIST "%systemdrive%\Program Files\Microsoft Office\OFFICE11\outlook.exe" GOTO EOF "%systemdrive%\Program Files\Microsoft Office\OFFICE11\outlook.exe" /importprf "P:\software\ldap\ldap.prf" ECHO %TIME% - %DATE% >> "%systemdrive%\EGN\checks\ldap.chk" :EOF ---------------------------------------------------------------------------- ---------------------------------------------- Ffxupdate.bat: (this is a bit over my head, as I am really just a hack. I manage to make it work for this and other software, but all the for/find stuff I really need to learn better......) @Echo ON IF not exist "C:\Program Files\Mozilla Firefox" goto :EOF Setlocal Set CV="2.0.0.14 (en-US)" Set "key=HKLM\SOFTWARE\Mozilla\Mozilla Firefox" For /f "tokens=3* delims= " %%# In ( 'Reg query "%key%" /v CurrentVersion ^|Find "REG_" 3^>Nul') Do Set rel="%%#" If Not [%rel%]==[%CV%] Start "" /wait %software%\mozilla\firefox\ffx20014.exe -ms del "%allusersprofile%\desktop\Mozilla Firefox.lnk" Goto :Eof ---------------------------------------------------------------------------- ---------------------------------------------- stats.bat: (need to expand for greater coverage) ECHO on ECHO ****************************Logonscript Contents******************* >> "%logs%\%computername%.txt" type "c:\egn\logon.bat" >> "%logs%\%computername%.txt" ECHO ****************************END Logonscript Contents******************* >> "%logs%\%computername%.txt" ECHO . ECHO . ECHO **************Login User, Date, and Time************************* >> "%logs%\%computername%.txt" ECHO Login - %username% - %date% - %time% >> "%logs%\%computername%.txt" ECHO **************END Login Date and Time************************* >> "%logs%\%computername%.txt" ECHO . ECHO . ECHO **************IP INFORMATION************************* >> "%logs%\%computername%.txt" ipconfig /all >> "%logs%\%computername%.txt" ECHO **************END IP INFORMATION************************* >> "%logs%\%computername%.txt" ECHO . ECHO . ECHO **************Get IE Version************************* >> "%logs%\%computername%.txt" reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer" /v Version >> "%logs%\%computername%.txt" ECHO **************END IE Version************************* >> "%logs%\%computername%.txt" ECHO . ECHO . ECHO **************Check for Websuite************************* >> "%logs%\%computername%.txt" if EXIST "%systemdrive%\Program Files\Adp\ws2000\ws2000.exe" ECHO ADP installed >> "%logs%\%computername%.txt" if NOT EXIST "%systemdrive%\Program Files\Adp\ws2000\ws2000.exe" ECHO ADP NOT installed >> "%logs%\%computername%.txt" Reg query "HKLM\SOFTWARE\ADP\wsvc" /v Version >> "%logs%\%computername%.txt" ECHO **************END Check for Websuite************************* >> "%logs%\%computername%.txt" ECHO. ECHO. ---------------------------------------------------------------------------- -------------------------- Printers.vbs: ' ' Printers.vbs - Windows Logon Script. Set objNetwork = CreateObject("WScript.Network") objNetwork.AddWindowsPrinterConnection "\\server\Dell3115" ---------------------------------------------------------------------------- ---------------------------------------------- WSUSUPDATE.bat: (used to change wsus servers recently.) @echo off Net Stop "wuauserv" rename "%SystemRoot%\Windowsupdate.log" "Windowsupdate.logold" Echo Importing WSUS.reg %windir%\Regedit.exe /s %logondrive%\WSUS.reg Echo WSUS.reg imported succesfully Net Start "wuauserv" Echo Forcing update detection wuauclt /detectnow Wsus.reg: (sets the wsus server) Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate] "WUServer"="http://xxx.xxx.xxx.xxx:8530" "WUStatusServer"="http://xxx.xxx.xxx.xxx:8530" [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU] "NoAutoRebootWithLoggedOnUSers"=dword:00000001 "RescheduleWaitTime"=dword:0000001e "LastWaitTimeout"=dword:00000000 "DetectionStartTime"=dword:00000000 "UseWUServer"=dword:00000001 "NoAutoUpdate"=dword:00000000 "AUOptions"=dword:00000004 "ScheduledInstallDay"=dword:00000000 "ScheduledInstallTime"=dword:00000022 "DetectionFrequencyEnabled"=dword:00000001 "DetectionFrequency"=dword:00000016 ---------------------------------------------------------------------------- ---------------------------------------------- What I'd like to know is how to make a certain script run if the machine name is in a certain file. Put my parts department machinename in a parts.txt file, and then have the script check to see if it's there. (or perhaps some other way to accomplish this.....) I just haven't spent the time to look for this yet. Again, I hope this helps someone, and thanks to everyone on this list. And of course the Samba developers for Samba in the first place... Dennis -- To unsubscribe from this list go to the following URL and read the instructions: https://lists.samba.org/mailman/listinfo/samba
