Solved

Login script error

Posted on 2012-04-04
2
645 Views
Last Modified: 2012-04-04
I am trying to map network drive using the following vb script file on windows 2003 R2 but when user logging in, an error throws that

Object required: NameSpace(...)
Line 14
vbscript runtime error

the code:
Dim objNetwork, strDrive, objShell, objUNC
Dim strRemotePath, strDriveLetter, strNewName

strDriverLetter = "W:"
strRemotePath = "\\home\Home share$"
strNewName = "myFolder"

Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

'Section which actually (re)names the Mapped Drive

Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter).Self.Name = strNewName

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortCut(strDesktop & "\myFolder.lnk")
oShellLink.TargetPath = WScript.ScriptFullName
oShellLink.WindowsStyle = 1
oShellLink.TargetPath = "W:\"
oShellLink.WorkingDirectory = "w:\"
oShellLink.Save

WScript.Quit

Please help me to fix the error.

thanks
0
Comment
Question by:ayha1999
[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
2 Comments
 
LVL 12

Accepted Solution

by:
prashanthd earned 250 total points
ID: 37807295
Can you check if the drive has been mapped successfully?
0
 
LVL 7

Author Closing Comment

by:ayha1999
ID: 37807368
the error was typo. strDriveLetter not strDriverLetter, so it was not mapped.

Thanks
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

733 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