Advertisement

07.23.2008 at 07:11AM PDT, ID: 23588549
[x]
Attachment Details

VB Logon Script not working correctly

Asked by smuth in VB Script, Programming Languages, Visual Basic Programming

Tags: vbscript

Purplepomegranite helped me with this script yesterday and it works perfectly on my machine, but when I try it on a couple of test users with GP or manually running it, they are getting the following error message:

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

*** Set time from server ***
*** Map Shared and Apps drives ***
Z:\SfldLogon.vbs(18, 1) WSHNetwork.RemoveNetworkDrive: This network connection d
oes not exist.

The user did not have any of his network connections so there was nothing there to disconnect, but I am not sure how to change the script to go to the next line and map the drive if the connection is not already there for disconnection. As I stated it is working on my machine, but it does not appear to disconnect the drives first. It looks like it is just going to the group membership section.

Thanks, Scott...Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
' First force the script to use the command line, so we can see Echo's
If LCase(Right(Wscript.FullName, 11)) = "wscript.exe" Then
	strPath = Wscript.ScriptFullName
	strCommand = "%comspec% /k cscript  """ & strPath & """"
	Set objShell = CreateObject("Wscript.Shell")
	objShell.Run(strCommand), 1, True
	Wscript.Quit
End If
 
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
 
WScript.Echo "*** Set time from server ***"
strCommand = "net time \\dc1 /set /yes"
objShell.Run strCommand, 1, True
 
WScript.Echo "*** Map Shared and Apps drives ***"
objNetwork.RemoveNetworkDrive "I:", True, True
WScript.Sleep 200
objNetwork.MapNetworkDrive "I:", "\\fs3\iso", False
objNetwork.RemoveNetworkDrive "M:", True, True
WScript.Sleep 200
objNetwork.MapNetworkDrive "M:", "\\fs3\marketing", False
objNetwork.RemoveNetworkDrive "S:", True, True
WScript.Sleep 200
objNetwork.MapNetworkDrive "S:", "\\fs3\shared", False
 
WScript.Echo "*** Map Home drives ***"
objNetwork.RemoveNetworkDrive "P:", True, True
WScript.Sleep 200
objNetwork.MapNetworkDrive "P:", "\\fs1\home$\" & objNetwork.UserName, False
 
WScript.Echo "*** Map Drives as per group membership ***"
 
Set objSysInfo = CreateObject("ADSystemInfo")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
 
' Loop and check group membership for user
on error resume next
For Each strGroup in objUser.MemberOf
	strGroupPath = "LDAP://" & strGroup
	Set objGroup = GetObject(strGroupPath)
	strGroupName = objGroup.CN
	WScript.Echo objSysInfo.Username & ": " & strGroupName
	
	Select Case strGroupName
		Case "ops"
			WScript.Echo "*** Map Root drive ***"
			objNetwork.RemoveNetworkDrive "L:", True, True
			WScript.Sleep 200
			objNetwork.MapNetworkDrive "L:", "\\fs3\PDP", False
		Case "pdp"
			WScript.Echo "*** Map LanAdmin drive ***"
			objNetwork.RemoveNetworkDrive "O:", True, True
			WScript.Sleep 200
			objNetwork.MapNetworkDrive "O:", "\\fs3\OPS", False
		case else
			WScript.Echo objSysInfo.Username & ": " & strGroupName
	End Select
Next
[+][-]07.23.2008 at 07:55AM PDT, ID: 22069959

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 08:16AM PDT, ID: 22070163

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 08:38AM PDT, ID: 22070406

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 08:42AM PDT, ID: 22070435

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 08:47AM PDT, ID: 22070497

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 08:51AM PDT, ID: 22070531

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, Programming Languages, Visual Basic Programming
Tags: vbscript
Sign Up Now!
Solution Provided By: Chris-Dent
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.23.2008 at 08:51AM PDT, ID: 22070536

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.23.2008 at 08:53AM PDT, ID: 22070557

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628