PDA

View Full Version : Login Script & Drive Mappings (W2K)



C0deTw1ster
05-20-2002, 01:23 PM
Hi. I have a WSH login Script that works great except for the group-based drive mappings. It appears to fail out as soon as it gets to a group that tries to map more than one drive. Below is a sample of how I have this setup. Can anybody see anything wrong? Or have any suggestions?

' Map Drives Based on Group Membership
If INGROUP ("MON_IT_G") Then MapDrive "Q:", "\\MONSVR7\APPS", 0
MapDrive Drv & ":", "\\LZBS3601\IT", 0
Ltr = Ltr + 1
ElseIf INGroup ("MON_IT_NETSERV_G") Then
MapDrive Drv & ":", "\\LZBS3601\NETSERV", 0
Ltr = Ltr + 1
ElseIf INGROUP ("MON_IT_OPER_OPEN_G") Then
MapDrive Drv & ":", "\\LZBS3601\CHANGECONT", 0
Ltr = Ltr + 1
MapDrive Drv & ":", "\\MONSVR5\OPENSYSTEMS", 0
Ltr = Ltr + 1
ElseIf INGROUP ("MON_IT_ADMIN_G") Then
MapDrive Drv & ":", "\\LZBS3601\ADMIN", 0
Ltr = Ltr + 1
ElseIf INGROUP ("MON_IT_APPL_G") Then
MapDrive Drv & ":", "\\LZBS3601\APPL", 0

jdharm
05-21-2002, 03:05 PM
I'm not much on scripting, but since no one else has answered...I'm trying to learn a little so I'll ask some questions and maybe they'll shed some light on the problem.

Am I reading correctly: a user may be a member of multiple groups so you check for membership of each group and map a certain share as a drive for each group, advancing the drive letter one step for each drive mapped, starting with Q.

Questions:

Do you cancel out any possibly persistant drive mappings earlier in the script to avoid any conflicts?

Is it so important that the drive letters be sequential?

You advance the variable Ltr by one step, but use the variable Drv as the letter of the drive to be mapped. Am I missing an assumed bit of code wherein you use Ltr to assign the next letter in the alphabet to Drv? Can you advance a ASCII string one character in the chart by adding 1? I think that is the part that is really throwing me.

Josh

"What we call 'Progress' is the exchange of one nuisance for another nuisance."

Jama
05-22-2002, 01:24 AM
Although you have correctly incremented the value of “Ltr”, the value of “Drv” has remained constant throughout the part of the code you have shown us.

Since you are using “Drv” to retrieve the letter to which you are mapping a drive, your script will fail when you attempt to map a second drive for a user because you’ve already used that drive letter to map the first drive.
So far this has been happening when a user is a member of more than one group, because that’s when you have to map more than one drive.

To work around this, you’ll have to “refresh” Drv to reflect the new value of Ltr.
In plain English, you’ll have to add **Drv = Ltr** after each **Ltr = Ltr + 1** line.

When working with variables that have their values set or changed at run time, I always scatter a few message boxes between my code to check that the variables are getting the value I want them to.

I’ve commented out the part of the code that maps a drive and added message boxes, see how Drv’s value never changes?

Ltr = Asc("Q")
Drv = (Chr(Ltr))

'Map Drives Based On Group Membership
'If INGROUP ("MON_IT_G") Then
‘MapDrive "Q:", "\\MONSVR7\APPS", 0
'MapDrive Drv & ":", "\\LZBS3601\IT", 0
Ltr = Ltr + 1
Wscript.echo "Drv = " & Drv & " " & "Ltr = " & (Chr(Ltr))
'ElseIf INGroup ("MON_IT_NETSERV_G") Then
'MapDrive Drv & ":", "\\LZBS3601\NETSERV", 0
Ltr = Ltr + 1
Wscript.echo "Drv = " & Drv & " " & "Ltr = " & (Chr(Ltr))
'ElseIf INGROUP ("MON_IT_OPER_OPEN_G") Then
'MapDrive Drv & ":", "\\LZBS3601\CHANGECONT", 0
Ltr = Ltr + 1
Wscript.echo "Drv = " & Drv & " " & "Ltr = " & (Chr(Ltr))
'MapDrive Drv & ":", "\\MONSVR5\OPENSYSTEMS", 0
Ltr = Ltr + 1
Wscript.echo "Drv = " & Drv & " " & "Ltr = " & (Chr(Ltr))
'ElseIf INGROUP ("MON_IT_ADMIN_G") Then
'MapDrive Drv & ":", "\\LZBS3601\ADMIN", 0
Ltr = Ltr + 1
Wscript.echo "Drv = " & Drv & " " & "Ltr = " & (Chr(Ltr))
'ElseIf INGROUP ("MON_IT_APPL_G") Then
'MapDrive Drv & ":", "\\LZBS3601\APPL", 0

Fix;

Ltr = Asc("Q")
Drv = (Chr(Ltr))

'Map Drives Based On Group Membership
If INGROUP ("MON_IT_G") Then
MapDrive (Chr(Ltr)) & ":", "\\MONSVR7\APPS", 0
Ltr = Ltr + 1
MapDrive (Chr(Ltr)) & ":", "\\LZBS3601\IT", 0
Ltr = Ltr + 1

Or


'If INGROUP ("MON_IT_G") Then
MapDrive "Q:", "\\MONSVR7\APPS", 0
Ltr = Ltr + 1
Drv = Ltr
MapDrive Drv & ":", "\\LZBS3601\IT", 0
Ltr = Ltr + 1
Drv = Ltr

Jama

Since you have not submitted the full script nor the actual error message you are receiving, my advice is based on assumptions. If this didn’t resolve your problem, then please tell us the exact error message or post the complete script here.

jith
08-07-2002, 07:24 PM
group-based drive mappings - Can you give me the full script how can I carete a group based drive mapping in Windows NT4 And AD. I tryed your script.. but that is not complete... Can you help..
Thanks

Jith Jkkothoor@krollworldwide.com

C0deTw1ster
08-07-2002, 07:38 PM
Wow, I forgot I even posted this. I did end up fixing the group mapping thing. Notice that you can specify certain drive letters to be used for specific shares by identifying the exact drive letter in the "MapDrive" line. Other wise use the "&" to get the next available. Hope this helps you. Here's a sample of the Map Drives section from the revised code...

' Map Drives Based on Group Membership

If INGROUP ("MON_IT_G") Then
MapDrive "Q:", "\\MONSVR7\APPS", 0
MapDrive Drv & ":", "\\LZBS3601\IT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If

If INGroup ("MON_IT_NETSERV_G") Then
MapDrive Drv & ":", "\\LZBS3601\NETSERV", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End IF

If INGROUP ("MON_IT_OPER_OPEN_G") Then
MapDrive Drv & ":", "\\LZBS3601\CHANGE CONT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
MapDrive Drv & ":", "\\MONSVR5\OPENSYSTEMS", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If

If INGROUP ("MON_IT_ADMIN_G") Then
MapDrive Drv & ":", "\\LZBS3601\ADMIN", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If

If INGROUP ("MON_IT_APPL_G") Then
MapDrive Drv & ":", "\\LZBS3601\APPL", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If

If INGROUP ("MON_IT_BUSENG_G") Then
MapDrive Drv & ":", "\\LZBS3601\BUSENG", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If

If INGROUP ("MON_IT_CAD_G") Then
MapDrive Drv & ":", "\\LZBS3601\CAD", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If

If INGROUP ("MON_IT_DBASE_G") Then
MapDrive Drv & ":", "\\LZBS3601\DBASE", 0
Ltr = Ltr + 1
Drv = chr(Ltr)

C0deTw1ster
08-07-2002, 07:44 PM
All, here is the final FULL working script. I've been using this in a production environment for a few weeks now with no problems. NOTE: Client machines will need WSH 5.6 for the installation function to work correctly.

'************************************************* ********************************
' Login Script
'************************************************* ********************************
' Set Environment Variables
'************************************************* ********************************
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WSHFso = CreateObject("Scripting.FileSystemObject")
Set MSIE = CreateObject("InternetExplorer.Application")
If err.number <> 0 Then
Wscript.Echo "Login Script Failed" & vbCrLf & "Reason: " & Err.Description
Wscript.Quit
End IF
'************************************************* ********************************
' Main Process
'************************************************* ********************************
On Error Resume Next
' Declare Variables
sTitle = "Processing Logon Script, please wait..."
DOMAIN = WSHNetwork.UserDomain
LOGONSERVER = GetServer()
USERNAME = ""
WORKSTATION = ""
REGLOC = "HKLM\Software\NetworkLogin\"
FILESRV = "MONS6000"
INSTALL_DIR = "\\" & FILESERVER & "\Update\"
HOME = ""
UNAME = ""
Ltr = 83
Drv = chr(Ltr)
NErr = 0
WORKSTATION = WSHNetwork.ComputerName
While USERNAME = ""
USERNAME = WSHNetwork.UserName
MyGroups = GetGroups(DOMAIN, UserNAME)
Wend
'************************************************* ********************************
' Setup Display Box, Greet User, and Execute Login Process
'************************************************* ********************************
SetupMSIE
MSIE.Document.Write "<HTML><TITLE>" & sTitle & "</TITLE><BODY bgcolor=#ffffff><FONT FACE=TREBUCHET>"
If Hour(Now) < 12 Then
MSIE.Document.Write "<center><B>Good Morning, " & USERNAME & "</B><BR>"
ElseIf Hour(Now) < 18 Then
MSIE.Document.Write "<center><B>Good Afternoon, " & USERNAME & "</B><BR>"
Else
MSIE.Document.Write "<center><B>Good Evening, " & USERNAME & "</B><BR>"
End If
MSIE.Document.Write "<HR>"
If WSHShell.RegRead(REGLOC & "Setup") <> "Yes" Then
Install
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Reboot()
next
Else
GrpMeb USERNAME
WSHShell.Run("\\" & LOGONSERVER & "\GEN\Trend\lzbtrend.bat /Q:A "), 1, True
CleanUp
End If
If NErr = 0 Then
MSIE.Document.Write "</FONT></Body></HTML>"
MSIE.Quit
Else
MSIE.Document.Write "<BR><BR>There were errors while running the script. Please contact local support personnel for further help"
MSIE.Document.Write "<BR>Closing in 5 seconds..."
MSIE.Document.Write ",</FONT></Body></HTML>"
Wscript.Sleep 5000
MSIE.Quit
End If
Wscript.Quit
'************************************************* ********************************
'Map Network Drives Subroutine
'************************************************* ********************************
'Function: GetGroups
'Arguments: strDomain - logon domain name
' strUserID - user id
'Description: Get list of group memberships
'************************************************* ********************************
Function GetGroups(DOMAIN, USERNAME)
Set objUser = GetObject("WinNT://" & DOMAIN & "/" & USERNAME)
GetGroups=""
For Each objGroup In objUser.Groups
GetGroups=GetGroups & "[" & UCase(objGroup.Name) & "]"
Next
End Function
'************************************************* *******************************
'Function: InGroup
'Arguments: strGroup - group to check membership of
'Description: Returns True/False
'Note: Requires pre-initialization of MyGroups variant
'************************************************* *******************************
Function InGroup(strGroup)
InGroup=False
If InStr(MyGroups,"[" & UCase(strGroup) & "]") Then
InGroup=True
End If
End Function
'************************************************* *******************************
Sub GrpMeb(UNAME)
'************************************************* *******************************
' Map Common Drives
MapDrive "L:", "\\MONSVR2\CorpInfo", 0
'************************************************* *******************************
' Map Drives Based on Group Membership
If INGROUP ("MON_IT_G") Then
MapDrive "Q:", "\\MONSVR7\APPS", 0
MapDrive Drv & ":", "\\LZBS3601\IT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGroup ("MON_IT_NETSERV_G") Then
MapDrive Drv & ":", "\\LZBS3601\NETSERV", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End IF
If INGROUP ("MON_IT_OPER_OPEN_G") Then
MapDrive Drv & ":", "\\LZBS3601\CHANGE CONT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
MapDrive Drv & ":", "\\MONSVR5\OPENSYSTEMS", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_ADMIN_G") Then
MapDrive Drv & ":", "\\LZBS3601\ADMIN", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_APPL_G") Then
MapDrive Drv & ":", "\\LZBS3601\APPL", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_BUSENG_G") Then
MapDrive Drv & ":", "\\LZBS3601\BUSENG", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_CAD_G") Then
MapDrive Drv & ":", "\\LZBS3601\CAD", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_DBASE_G") Then
MapDrive Drv & ":", "\\LZBS3601\DBASE", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_OPER_DOC_G" or "MON_IT_OPER_OPER_G" or "MON_IT_OPER_SUP_G" or "MON_IT_OPER_TRAIN_G") Then
MapDrive Drv & ":", "\\MONSVR2\OPER", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_OPER_TCS_G") Then
MapDrive Drv & ":", "\\LZBS3601\N2000-06", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_TECHS_G") Then
MapDrive Drv & ":", "\\LZBS3601\TECHSERV", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_STRATECH_G") Then
MapDrive Drv & ":", "\\LZBS3601\STRATECH", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_PROJMGT_G") Then
MapDrive Drv & ":", "\\LZBS3601\PROJMAN", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IT_ASSTMGT_G") Then
MapDrive Drv & ":", "\\LZBS3601\ASSTMGT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_WRKSTN_ADMIN_G") Then
MapDrive Drv & ":", "\\MONS6000\APPS", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MRK_G") Then
MapDrive "Q:", "\\MONSVR6\APPS", 0
MapDrive Drv & ":", "\\MONSVR5\MRKTNG", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MRK_DPLAN_G") Then
MapDrive Drv & ":", "\\MONSVR5\DISPLAN", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IAUD_G") Then
MapDrive "Q:", "\\MONSVR7\APPS", 0
MapDrive Drv & ":", "\\MONSVR2\INTAUDIT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_FAB_G") Then
MapDrive "Q:", "\\MONSVR5\APPS", 0
MapDrive Drv & ":", "\\MONSVR5\FABRIC", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_PDEV_G") Then
MapDrive "Q:", "\\MONSVR6\APPS", 0
End If
If INGROUP ("MON_PDEV_MECHENG_G") Then
MapDrive Drv & ":", "\\MONSVR5\MECHENG", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_R&D_G") Then
MapDrive Drv & ":", "\\MONSVR5\********RD", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_PDEV_ENGSER_G") Then
MapDrive Drv & ":", "\\MONSVR5\ENGSER", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_PDEV_CNTRACT_G") Then
MapDrive Drv & ":", "\\MONSVR5\CON-RD", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_LTAX_G") Then
MapDrive "Q:", "\\MONSVR7\APPS", 0
MapDrive Drv & ":", "\\LZBS3601\LEGALTAX", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_ACCT_G") Then
MapDrive "Q:", "\\MONSVR7\APPS"
MapDrive Drv & ":", "\\MONSVR2\ACCTNG", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_CACCT_G") Then
MapDrive Drv & ":", "\\MONSVR2\COSTACCT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_GACCT_G") Then
MapDrive Drv & ":", "\\MONSVR2\GENACCT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_IENG_G") Then
MapDrive "Q:", "\\MONSVR6\APPS", 0
MapDrive Drv & ":", "\\MONSVR5\INDENG", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MERCH_G") Then
MapDrive "Q:", "\\MONSVR6\APPS", 0
MapDrive Drv & ":", "\\MONSVR5\MERCH", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
MapDrive Drv & ":", "\\MONSVR5\FABMERCH", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MES_G") Then
MapDrive Drv & ":", "\\MONSVR2\MES", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_CNTRCT_G") Then
MapDrive Drv & ":", "\\MONSVR5\CONTRACT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_CNTRCT_SALES_G") Then
MapDrive Drv & ":", "\\MONSVR5\CON-SALE", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_CNTRCT_SVC_G") Then
MapDrive Drv & ":", "\\MONSVR5\CON-SVC", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_CNTRCT_MKTG_G") Then
MapDrive Drv & ":", "\\MONSVR5\CON-MKTG", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_CNTRCT_HC_G") Then
MapDrive Drv & ":", "\\MONSVR5\CON-HC", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MFG_G") Then
MapDrive Drv & ":", "\\MONSVR2\MFG", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MFGRES_G") Then
MapDrive Drv & ":", "\\MONSVR2\MFG-RES", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MFG_PLAYOUT_G") Then
MapDrive Drv & ":", "\\MONSVR2\PLAYOUT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_PAYROLL_G" or "MON_CORPPAYROLL_G") Then
MapDrive Drv & ":", "\\MONSVR2\PAYROLL", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_CORPPAYROLL_G") Then
MapDrive Drv & ":", "\\MONSVR2\CORPPAYROLL", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MFGSERV_G") Then
MapDrive Drv & ":", "\\MONSVR5\MFGSERV", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_Sales&ServAdm_G") Then
MapDrive Drv & ":", "\\MONSVR5\SALESERVADM", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_EXPORT_G") Then
MapDrive Drv & ":", "\\MONSVR5\EXPORT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_ACCTSPAY_G") Then
MapDrive Drv & ":", "\\MONSVR2\ACCTSPAY", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_RESSALES_G") Then
MapDrive Drv & ":", "\\MONSVR5\RESSALES", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_MAILROOM_G") Then
MapDrive Drv & ":", "\\MONSVR2\MAILROOM", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_FILEROOM_G") Then
MapDrive Drv & ":", "\\MONSVR2\FILEROOM", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_BENEFITS-HR_G") Then
MapDrive Drv & ":", "\\MONSVR2\BENEFITS-HR", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_BENESOFT_G") Then
MapDrive "Q:", "\\MONSVR6\APPS", 0
End If
If INGROUP ("MON_FINSERV_G") Then
MapDrive Drv & ":", "\\MONSVR2\FINSERV", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_PURCHASING_G" or "MON_MATMGT_G") Then
MapDrive Drv & ":", "\\MONSVR5\MATRLS-PURCH", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_CREDIT_G") Then
MapDrive Drv & ":", "\\MONSVR2\CREDIT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_ACCTSREC_G") Then
MapDrive Drv & ":", "\\MONSVR2\ACCTSREC", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
If INGROUP ("MON_PDM_ALL_G") Then
MapDrive Drv & ":", "\\MONSVR2\PDM_ROLLOUT", 0
Ltr = Ltr + 1
Drv = chr(Ltr)
End If
End Sub
'************************************************* ********************************
' MapDrives Subroutine
' Maps Drives, Returns Error if something goes wrong.
' MAPDRIVE DriveLetter, UNCPath, Homedrive 1 - Yes, 0 - No
'************************************************* ********************************
Sub MapDrive(sDrive,sShare,sHome)
On Error Resume Next
WSHNetwork.RemoveNetworkDrive sDrive
Err.Clear
WSHNetwork.MapNetworkDrive sDrive,sShare
MSIE.Document.Write "<BR>Mapping " & sDrive & " to " & sShare
If sHome = 1 Then
HOME = sDrive
End If
if Err.Number <> 0 Then
MSIE.Document.Write "<BR><FONT COLOR=#FF6666>ERROR! Mapping network drive " & sDrive & " Reason: " & Err.Description & "</FONT>"
NErr = 1
End If
End Sub
'************************************************* *********************************
' Software Updates Subroutine
'************************************************* *********************************
Sub Install()
On Error Resume Next
MSIE.Document.Write "<BR>The logon script has determined this is the first time run your machine. New software is being downloaded to your computer and configurations set. The updates will take about 5 - 10 minutes to install, afterwards your computer will reboot automatically."
MSIE.Document.Write "<BR><BR>Please wait while the updates occur. If your computer stops responding or has an error message come up, please contact you local support personnel."
MSIE.Document.Write "<BR><FONT COLOR=#0000FF>"

WSHShell.RegWrite "HKLM\Software\NetworkLogin\" , 1 ,"REG_DWORD"
WSHShell.RegWrite "HKLM\Software\NetworkLogin\Installed\" , 1 ,"REG_DWORD"

MSIE.Document.Write "<BR>Installing Windows Script 5.6..."
' WSHShell.Run """copy \\MONS6000\Update\WSH\scripten.exe c:\temp""", 1, True
WSHShell.Run "\\MONS6000\Update\WSH\scripten /Q:A /R:N ", 1, True
WSHShell.RegWrite "HKLM\Software\NetworkLogin\Installed\WSHScript", "Installed"

' MSIE.Document.Write "<BR>Installing COM Controls..."
' WSHShell.Run(INSTALL_DIR & "registry\setup.exe /q:a"), 1, True
' WSHShell.RegWrite "HKLM\Software\NetworkLogin\Installed\COMControls", "Installed"

WSHShell.RegWrite "HKLM\Software\NetworkLogin\Setup", "Yes"
MSIE.Document.Write "</FONT>"
End Sub
'************************************************* **********************************
' CleanUp Subroutine & Update System Settings
'************************************************* **********************************
Sub CleanUp()
On Error Resume Next
End Sub
'************************************************* **********************************
' Internet Explorer Setup Subroutine
'************************************************* **********************************
Sub SetupMSIE
MSIE.Navigate "About:Blank"
MSIE.ToolBar = False
MSIE.StatusBar = False
MSIE.Resizable = False

Do
Loop While MSIE.Busy

SWidth = MSIE.Document.ParentWindow.Screen.AvailWidth
SHeight = MSIE.Document.ParentWindow.Screen.AvailHeight
MSIE.Width = SWidth * .5
MSIE.Height = SHeight * .75
MSIE.Left = (SWidth - MSIE.Width)/2
MSIE.Top = (SHeight - MSIE.Height)/2

MSIE.Visible = True
End Sub
'************************************************* ***********************************
' Get the Logon Server from The Share Name
'************************************************* ***********************************
Function GetServer()
strShareName = "\\Unknown\Server"
On Error Resume next
Set colDrives = WshNetwork.EnumNetworkDrives
If colDrives.Count > 0 Then
For i = 0 To colDrives.Count - 1 Step 2
strShareName = colDrives(i+1)
If InStr(UCase(strShareName),"NETLOGON") Then
Exit For
End If
Next
End If
GetServer = Left(strShareName,InStr(3,strShareName,"\")-1)
End Function
'************************************************* ************************************

jith
08-08-2002, 09:28 AM
Thans for the reply.. I want to know how can I put that in .VBS script.

When I try to put that in a .VBS script like this..

IF InGroup ("Domain\Groupname") THEN

WshNetwork.MapNetworkDrive "F:", "\\server\hsare"
END IF

This is giving me Type mismatch.

Thanks.