Solved

I'm having trouble with a vbscript that maps network drives

Posted on 2009-04-07
5
227 Views
Last Modified: 2012-05-06
This is a three-part issue:

1. Out of nowhere, our network drive mapping disappeared on our desktops and laptops. What would cause that?

2. On at least a couple of my desktops, it won't even give me an option to map a network drive under My Computer. How can I give these users and/or computers mapping capability?

3. I receive a Microsoft VBScript compilation (800A0400) Expected statement error on a computer and user I recently added to the domain. There's a problem with the last line.  The code is listed below.
Const Drive_H     = "cn=fake1"
Const Drive_S     = "cn=fake2"
Const Drive_L     = "cn=fake3"
Const Drive_V     = "cn=fake4"
Const Drive_M     = "cn=fake5"
Const Drive_Y     = "cn=fake6"
 
Dim wshNetwork,strUserName
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
 
' msgbox (wshNetwork.UserName)
 
strGroups = LCase(Join(CurrentUser.MemberOf))
 
' msgbox (strGroups)
 
On Error Resume Next
 
If InStr(strGroups, Drive_Y) Then
    WshNetwork.RemoveNetworkDrive "y:", yes, yes 
    wshNetwork.MapNetworkDrive "y:", "\\server\sharedfolder$"
end if
 
If InStr(strGroups, Drive_H) Then
    WshNetwork.RemoveNetworkDrive "h:", yes, yes 
    wshNetwork.MapNetworkDrive "h:", "\\server\users\" & wshNetwork.UserName
end if
If InStr(strGroups, Drive_L) Then
    WshNetwork.RemoveNetworkDrive "l:", yes, yes 
    wshNetwork.MapNetworkDrive "l:", "\\server2\CC40"
end if
 If InStr(strGroups, Drive_M) Then
    WshNetwork.RemoveNetworkDrive "m:", yes, yes 
    wshNetwork.MapNetworkDrive "m:", "\\server\sharedfolder2$"
end if
If InStr(strGroups, Drive_S) Then
    WshNetwork.RemoveNetworkDrive "s:", yes, yes 
    wshNetwork.MapNetworkDrive "s:", "\\server\sharedfolder3$"
    
End If
If InStr(strGroups, Drive_V) Then
    WshNetwork.RemoveNetworkDrive "v:", yes, yes 
    wshNetwork.MapNetworkDrive "v:", "\\server\sharedfolder4$"
end if
 
Wscript.Quit
 
 
\\server\sysvol\ya.local\scripts\SBS_LOGIN_SCRIPT.bat

Open in new window

0
Comment
Question by:TexasEx95
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 24094029
Hi there,

1) No idea....that's a bit broad...perhaps related to point 2 though....

2) Try having a look at this registry value
HKEY_CURRENT_USER
Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
Name: NoNetConnectDisconnect
Value: 1 Enable
Value: 0 Disable

and if that's set, there may be a group policy setting configured to prevent the mapping of drives.

3) This line
\\server\sysvol\ya.local\scripts\SBS_LOGIN_SCRIPT.bat

should be
Set objShell = CreateObject("WScript.Shell")
objShell.Run "\\server\sysvol\ya.local\scripts\SBS_LOGIN_SCRIPT.bat", 1, True

Regards,

Rob.
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 500 total points
ID: 24094044
The group policy setting looks to be
Administrative Templates\Windows Components\Windows Explorer\Remove Map Network Drive and Disconnect Network Drive

Remove "Map Network Drive" and "Disconnect Network Drive"
http://msdn.microsoft.com/en-us/library/ms812045.aspx

Regards,

Rob.
0
 

Author Comment

by:TexasEx95
ID: 24100824
RobSampson,

I'm very much a newbie to vbscript. When you say remove "Map Network Drive" and "Disconnect Network Drive," would lines 22 and 23 then read the following as an example?

WshNetwork. "y:", yes, yes
wshNetwork. "y:", "\\server\sharedfolder$"

Thanks for your help,
TexasEx95
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 500 total points
ID: 24101758
These lines remove and connect a drive:
   WshNetwork.RemoveNetworkDrive "h:", yes, yes
   WshNetwork.MapNetworkDrive "h:", "\\server\users\"

But the "yes" should be changed to True throughout.

   WshNetwork.RemoveNetworkDrive "h:", True, True
   WshNetwork.MapNetworkDrive "h:", "\\server\users\"

Regards,

Rob.
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Experts-Exchange users below are the steps you can follow to upgrade your Lync server to latest CU's or cumulative updates. Note: Perform it during non-production hours.   Step 1: Backup your lync and SQL server database. Follow below article: h…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question