I am having a tough time finding simple information about what I think is such a simple request.
I want to map several drive letters in login scripts for our users on a windows network (some 2k, and some XP user machines) with Active directory. Simple right? One would think that lots of people would want this. Actictive directory has a great place under the user properties for "profile" where you can put in a home directory but you have to write scripts for more than one mapping apparently. I want users not only to have their home drive mapped but also their departmental shares.
I came from a Netware environment where making these kind of mapping was a breeze! However MS seems to make it a huge deal.
This is the best example I could find on their web site
"// JScript.
var oNet, sUser, cInitial, startTime;
oNet = new ActiveXObject("WScript.Network");
// Get the user name. On Windows 98 and Windows ME, the use may not be logged
// on when the script starts running; keep checking every 1/2 a
// second until they are logged on
sUser = oNet.UserName;
startTime = new Date();
while (sUser == "")
{
var curTime = new Date();
if (curTime ? startTime > 30000) WScript.Quit();
WScript.Sleep(500);
sUser = oNet.UserName;
}
// Add a share for the "h" drive and the printer, based on the
// first letter of the user's name
cInitial = sUser.charAt(0).toUpperCase();
if (cInitial < "L")
{
oNet.MapNetworkDrive("h:", "\\\\server1\\users\\" + sUser);
oNet.AddWindowsPrinterConnection("\\\\printer1\\hp", "HP LaserJet 4");
}
else
{
oNet.MapNetworkDrive("h:", "\\\\server2\\users\\" + sUser);
oNet.AddWindowsPrinterConnection("\\\\printer2\\hp", "HP LaserJet 4");
}
' VBScript.
Option Explicit
Dim oNet, sUser, cInitial, startTime
' Helper object
Set oNet = CreateObject("WScript.Network")
' Get the user name. On Windows 9x, the use may not be logged
' on when the script starts running; keep checking every 1/2 a
' second until they are logged on.
sUser = oNet.UserName
startTime = Now
Do While sUser = ""
If DateDiff("s", startTime, Now) > 30 Then Wscript.Quit
Wscript.Sleep 500
sUser = oNet.UserName
Loop
' Add a share for the "h" drive and the printer, based on the
' first letter of the user's name
cInitial = UCase(Left(sUser, 1))
If (cInitial < "L") Then
oNet.MapNetworkDrive "h:", "\\server1\users\" & sUser
oNet.AddWindowsPrinterConnection "\\printer1\hp", "HP LaserJet 4"
Else
oNet.MapNetworkDrive "h:", "\\server2\users\" & sUser
oNet.AddWindowsPrinterConnection "\\printer2\hp", "HP LaserJet 4"
End If"
Come on! That is a huge pain in the butt plus it about requires a detailed knowledge of JScript! All I want is to map the stupid letter I to a network location!
Anyway does anyone know of a good resource for writing a script to do that? I am not opposed to software that helps me write a JScript if I have to but I the simplest solution is the best as far as I am concerned.
Thanks
I want to map several drive letters in login scripts for our users on a windows network (some 2k, and some XP user machines) with Active directory. Simple right? One would think that lots of people would want this. Actictive directory has a great place under the user properties for "profile" where you can put in a home directory but you have to write scripts for more than one mapping apparently. I want users not only to have their home drive mapped but also their departmental shares.
I came from a Netware environment where making these kind of mapping was a breeze! However MS seems to make it a huge deal.
This is the best example I could find on their web site
"// JScript.
var oNet, sUser, cInitial, startTime;
oNet = new ActiveXObject("WScript.Network");
// Get the user name. On Windows 98 and Windows ME, the use may not be logged
// on when the script starts running; keep checking every 1/2 a
// second until they are logged on
sUser = oNet.UserName;
startTime = new Date();
while (sUser == "")
{
var curTime = new Date();
if (curTime ? startTime > 30000) WScript.Quit();
WScript.Sleep(500);
sUser = oNet.UserName;
}
// Add a share for the "h" drive and the printer, based on the
// first letter of the user's name
cInitial = sUser.charAt(0).toUpperCase();
if (cInitial < "L")
{
oNet.MapNetworkDrive("h:", "\\\\server1\\users\\" + sUser);
oNet.AddWindowsPrinterConnection("\\\\printer1\\hp", "HP LaserJet 4");
}
else
{
oNet.MapNetworkDrive("h:", "\\\\server2\\users\\" + sUser);
oNet.AddWindowsPrinterConnection("\\\\printer2\\hp", "HP LaserJet 4");
}
' VBScript.
Option Explicit
Dim oNet, sUser, cInitial, startTime
' Helper object
Set oNet = CreateObject("WScript.Network")
' Get the user name. On Windows 9x, the use may not be logged
' on when the script starts running; keep checking every 1/2 a
' second until they are logged on.
sUser = oNet.UserName
startTime = Now
Do While sUser = ""
If DateDiff("s", startTime, Now) > 30 Then Wscript.Quit
Wscript.Sleep 500
sUser = oNet.UserName
Loop
' Add a share for the "h" drive and the printer, based on the
' first letter of the user's name
cInitial = UCase(Left(sUser, 1))
If (cInitial < "L") Then
oNet.MapNetworkDrive "h:", "\\server1\users\" & sUser
oNet.AddWindowsPrinterConnection "\\printer1\hp", "HP LaserJet 4"
Else
oNet.MapNetworkDrive "h:", "\\server2\users\" & sUser
oNet.AddWindowsPrinterConnection "\\printer2\hp", "HP LaserJet 4"
End If"
Come on! That is a huge pain in the butt plus it about requires a detailed knowledge of JScript! All I want is to map the stupid letter I to a network location!
Anyway does anyone know of a good resource for writing a script to do that? I am not opposed to software that helps me write a JScript if I have to but I the simplest solution is the best as far as I am concerned.
Thanks