troubleshooting Question

VB scipt to map a network drive

Avatar of gbollyd
gbollyd asked on
Visual Basic Classic
5 Comments2 Solutions709 ViewsLast Modified:
I will be grateful if someone can tell me what am doing wrong, the script below is mean't to map network drive but everytime am getting this error.

Script: C:\Document and settings\ewhitsi\desktop\simple.vbs
Line : 1
Char : 1
Error : Invalid Character
Code : 800A0408
Source : Microsoft VBSCRIPt compilation error

-----------------------------------------------------------------------------------------------------------------

The script start from here

-------------------------------------------------------------------------------------------------------------------
Sub Map_S_Drive()
On Error Resume Next

Const User = "ewhitesi"
Const Password = "password9"

Dim NW, FSO

Set FSO = CreateObject("Scripting.FileSystemObject")

If not FSO.DriveExists("S:") Then
Set NW = CreateObject("WScript.Network")
NW.MapNetworkDrive "S:", "\\snap425880\data$", False, User, Password
Set NW = Nothing
End If

If FSO.DriveExists("S:") Then
MsgBox("S drive is mapped.")
Else
MsgBox("S drive did NOT map!" & vbcrlf & vbcrlf & Err.description)
End If

Set FSO = Nothing
End Sub

---------------------------------------------------------------------------------------------------------------------


Please, help.
If there is alternative simple one i will be grateful.

Futher, the above was copieid from a web site.

Thanks
ASKER CERTIFIED SOLUTION
JesterToo

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros