Useful Logon Script Commands

Solution 1:

I might get down voted for this, but so be it. I've always considered logon scripts to be kind of hack'ish and try to only use them as a last resort. There are so many ways to manage systems and users these days with things like Group Policy, Group Policy Preferences, and SCCM/SMS. I mean, there's always going to be cases where there just isn't a better way to do things. But many of the examples provided so far can easily be done without a login script like installing software and mapping network drives.

Solution 2:

Here's one of my favorites. We've got 700+ users and various divisions and subgroups that require their own drives. We're mapping based on username currently:

if %username% == [username] net use /delete Z:\
if %username% == [username] net use Z: \servername\share

another is the mapping of homedrives:

net use H: \homeserver\%username% /persistent:yes

Solution 3:

For drive mappings we actually use vbscript (actually we use .vbs instead of .bat files regardless for login scripts):

Set WshNetwork = CreateObject("WScript.Network") WshNetwork.MapNetworkDrive "H:", "\fwmnas\qip"

I also have part of it necessary to determine whether the OS is x86 or x64 based:

'Determine if OS is 32 bit or 64 bit first

Set WshShell = WScript.CreateObject("WScript.Shell") X = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE") If X = "x86" Then

That's very basic but basically you have an IF THEN ELSE part that says if it is 32 bit do this otherwise do this...I just left out the rest of the code. If you are interested in more of it let me know.

Solution 4:

I've already documented my kix login script which does pretty much the same things as you are requiring here: http://thisishelpful.com/kix-login-script-map-printers-network-drives-setting.html.

Take a look at it and let me know if you have any other requirements. I've personally found that KIX is really easy to understand and for a System Administrator who has never seen KIX scripting language before, you'll find it very easy and straight forward when you view the commands.