Re: UPDATE: Logon Script Problem
- From: jb6000 <jb6000@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 4 Jan 2007 09:21:00 -0800
Looks good now!
Thanks to your code that displays the error; I was able to figure out what I
was doing wrong.
I simply took out the function that was mapping the users personal drive
because the H: drive is already being assigned by the profile page in User
properties.
Thanks again!
"Richard Mueller" wrote:
I see nothing to explain why the version without the If statements would.
behave differently. However, the error indicates that the drive letter is
already in use, perhaps due to a persistent connection. You can trap this
error and attempt to remove existing mapping before trying again. Your
MapNetwordDrive subroutine could be similar to:
===========
Sub MapNetworkDrive(DriveLetter, NetworkPath)
On Error Resume Next
objWshNet.MapNetworkDrive DriveLetter, NetworkPath
If (Err.Number <> 0) Then
Err.Clear
objWshNet.RemoveNetworkDrive DriveLetter, True, True
If (Err.Number <> 0) Then
MsgBox ("Unable to remove mapping for drive " & DriveLetter _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Description: " Err.Description)
Exit Sub
End If
objWshNet.MapNetworkDrive DriveLetter, NetworkPath
If (Err.Number <> 0) Then
MsgBox ("Unable to map " NetworkPath & " to " & DriveLetter _
& vbCrLf & "Error Number: " & Err.Number _
& vbCrLf & "Description: " Err.Description)
End If
End If
End Sub
============
If this indicates the drive cannot be mapped, perhaps the user lacks
permissions. I added code to display the error number and description to aid
troubleshooting.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
"jb6000" <jb6000@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1207196C-833B-4F66-BA82-4DC11BCAFB39@xxxxxxxxxxxxxxxx
Hello,
This is an update of a post I did back on Dec 18th regarding a script
problem.
My script works fine when I create one script per user but when I try to
create a script with logic (to check for username) I get the following
error:
Error: The local device name is already in use.
Code: 80070055
Source: WSHNetwork.mapNetworkDrive
Below is a copy of my script with (or lack of) logic:
NOTE: The only part different between my working script and this script
that
gives me the error above is the Do Until section.
'Initialization Section
Option Explicit
' On Error Resume Next
Dim objWshNet
Dim WshShell
Dim strDesktopPath
Dim strStartupPath
Dim objShortcutUrl
Dim objShortcutLnk
Dim strFoundUser
Set objWshNet = WScript.CreateObject("WScript.Network")
Set WshShell = CreateObject("WScript.Shell")
strDesktopPath = WshShell.SpecialFolders("Desktop")
strStartupPath = WshShell.SpecialFolders("AllUsersStartup")
strFoundUser = "no"
'
'***************************
'* Main Processing Section *
'***************************
'
' Check for network username
Do Until strFoundUser = "yes"
If objWshNet.UserName = "jsmith" then
MapDeluxeFolder()
MapCompanyHomeFolder()
MapCommonCompanyFolders()
SetCommonCompanyShortcuts()
SetSalesAssocShortcuts()
strFoundUser = "yes"
End If
If objWshNet.UserName = "sadams" then
MapCompanyHomeFolder()
MapCommonCompanyFolders()
SetCommonITShortcuts()
SetCommonCompanyShortcuts()
strFoundUser = "yes"
End If
If objWshNet.UserName = "vbrown" then
MapDeluxeFolder()
MapCompanyHomeFolder()
MapCommonCompanyFolders()
SetCommonCompanyShortcuts()
SetSalesAssocShortcuts()
strFoundUser = "yes"
End If
strFoundUser = "yes"
Loop
WScript.Quit()
Sub MapNetworkDrive(DriveLetter, NetworkPath)
objWshNet.MapNetworkDrive DriveLetter, NetworkPath
End Sub
'*********************
'* Procedure Section *
'*********************
' START ************ MAPPED NETWORK FOLDERS ************************
Function MapDeluxeFolder()
MapNetworkDrive "G:", "\\Companybdc\GroupFolders\Deluxe39b"
End Function
Function MapCompanyHomeFolder()
MapNetworkDrive "H:", "\\Companybdc\homefolders\%username%"
End Function
Function MapCommonCompanyFolders()
MapNetworkDrive "M:", "\\192.xxx.xxx.5\symreceipts"
MapNetworkDrive "R:", "\\Companybdc\groupfolders\SCS system"
MapNetworkDrive "W:", "\\netcreditserv\ITSR SHARED"
End Function
Function MapCompanyManagerFolders()
MapNetworkDrive "T:", "\\Companybdc\groupfolders\Managers"
End Function
Function MapACCTCODFolders()
MapNetworkDrive "U:", "\\Companybdc\ACCT_COD"
End Function
'END ******************* MAPPED NETWORK FOLDERS *********************
'START ================== SHORTCUTS (INCLUDING STARTUP SHORTCUTS)
=========================
Function SetLendingShortcuts()
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\Andera
Online Membership.url")
objShortcutUrl.TargetPath =
"https://secure.andera.com/index.cfm?fiid=B1716D0F36EA482BAB472CEED63A459A&Action=admin.login"
objShortcutUrl.Save
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath &
"\EFunds.url")
objShortcutUrl.TargetPath = "https://www.efunds.com/"
objshortcutUrl.Save
End Function
Function SetCommonITShortcuts()
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath &
"\IPMonitor.url")
objShortcutUrl.TargetPath = "https://Companymonitor"
objShortcutUrl.Save
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\GFI
MailArchive.url")
objShortcutUrl.TargetPath = "http://ffgfiarchive/mailarchiver/main.aspx"
objShortcutUrl.Save
Set objShortcutLnk = WshShell.CreateShortcut(strDesktopPath & "\Remote
Desktop.lnk")
objShortcutLnk.TargetPath = "%windir%\system32\mstsc.exe"
objShortcutLnk.Save
End Function
Function SetCommonCompanyShortcuts()
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath &
"\EZlabor.url")
objShortcutUrl.TargetPath = "https://xxx.company.com/"
objShortcutUrl.Save
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\Company
Intranet.url")
objShortcutUrl.TargetPath = "http://192.xxx.xxx.249/"
objShortcutUrl.Save
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\CoWWW
Server.url")
objShortcutUrl.TargetPath = "http://192.xxx.xxx.5/cowww5/index.html"
objShortcutUrl.Save
Set objShortcutLnk = WshShell.CreateShortcut(strDesktopPath & "\Episys
Online Pub.lnk")
objShortcutLnk.TargetPath =
"\\Companybdc\GroupFolders\Public\EpisysDocs\EpisysOLP.chm"
objshortcutLnk.Save
End Function
Function SetCOPShortcuts()
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\Wave
Server.url")
objShortcutUrl.TargetPath = "https://wave.company.org"
objShortcutUrl.Save
End Function
Function SetSalesAssocShortcuts()
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\Wave
Server.url")
objShortcutUrl.TargetPath = "https://wave.company.org"
objShortcutUrl.Save
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\Company DI
Console Server.url")
objShortcutUrl.TargetPath = "https://www.company.org/Admin/"
objShortcutUrl.Save
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\MAPP
Server.url")
objShortcutUrl.TargetPath = " http://www.company.com/login.asp"
objShortcutUrl.Save
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\KBB
Server.url")
objShortcutUrl.TargetPath = "http://www.kbbcompany.com/"
- Follow-Ups:
- Re: UPDATE: Logon Script Problem
- From: Evan
- Re: UPDATE: Logon Script Problem
- References:
- UPDATE: Logon Script Problem
- From: jb6000
- Re: UPDATE: Logon Script Problem
- From: Richard Mueller
- UPDATE: Logon Script Problem
- Prev by Date: Re: UPDATE: Logon Script Problem
- Next by Date: Vista UAC problem with WScript.Shell Run method
- Previous by thread: Re: UPDATE: Logon Script Problem
- Next by thread: Re: UPDATE: Logon Script Problem
- Index(es):
Relevant Pages
|
Loading