what’s wrong with my logon script?
Home › Forums › Scripting › General Scripting › what’s wrong with my logon script?
- This topic has 30 replies, 6 voices, and was last updated 11 years, 5 months ago by
Candy.
-
AuthorPosts
-
chakotay2MemberJul 12, 2009 at 9:21 pm #143060What is wrong with this login script? Keep getting error (see jpg attachment for display)
The script works great, but throws an error often.
Const CSIDL_DESKTOP = &H10
Dim strLNKPath, strLNKname
Dim strTarget, strArguments
Dim sDriveLetter, strUNC
Dim objNetwork: set objNetwork = CreateObject(“WScript.Network”)
Dim WshShell: set WshShell = CreateObject(“WScript.Shell”)
Dim oShell: Set oShell = CreateObject(“Shell.Application”)
Dim oDesktop: Set oDesktopFolder = oShell.Namespace(CSIDL_DESKTOP)
Dim strDesktopFolder: strDesktopFolder = oDesktopFolder.Self.path
‘duplicate part between —- sDriveLetter = “Z:” strUNC = “[URL=”file://\serversharedfolder”]\serversharedfolder[/URL]” strLNKname = “Network Share 1”
‘———————————————————————–
‘ Mapping 1
‘
‘# Map drive:
sDriveLetter = “N:”
strUNC = “[URL=”file://\LPSERVERUsers”]\LPSERVERUsers[/URL] DocumentsInventory”
Call MapDrive(sDriveLetter, strUNC)
‘# Create shortcut:
strLNKPath = strDesktopFolder
strLNKname = “Inventory”
strTarget = “explorer.exe”
strArguments = “/e,/root,” & sDriveLetter & “”
Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
‘# Mapping’s alias: (optional – remove ‘rem’ to activate this routine)
rem Call NameMapping(strLNKname)
‘———————————————————————–
‘———————————————————————–
‘ Mapping 2
‘
‘# Map drive:
sDriveLetter = “R:”
strUNC = “[URL=”file://\LPSERVERUsers”]\LPSERVERUsers[/URL] DocumentsReceptionists”
Call MapDrive(sDriveLetter, strUNC)
‘# Create shortcut:
strLNKPath = strDesktopFolder
strLNKname = “Receptionist”
strTarget = “explorer.exe”
strArguments = “/e,/root,” & sDriveLetter & “”
Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
‘# Mapping’s alias: (optional – remove ‘rem’ to activate this routine)
rem Call NameMapping(strLNKname)
‘———————————————————————–
‘———————————————————————–
‘ Mapping 2
‘
‘# Map drive:
sDriveLetter = “S:”
strUNC = “[URL=”file://\LPSERVERHPDigitalSender”]\LPSERVERHPDigitalSender[/URL]”
Call MapDrive(sDriveLetter, strUNC)
‘# Create shortcut:
strLNKPath = strDesktopFolder
strLNKname = “Scanner”
strTarget = “explorer.exe”
strArguments = “/e,/root,” & sDriveLetter & “”
Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
‘# Mapping’s alias: (optional – remove ‘rem’ to activate this routine)
rem Call NameMapping(strLNKname)
‘———————————————————————–‘———————————————————————–
‘ Mapping 2
‘
‘# Map drive:
sDriveLetter = “V:”
strUNC = “[URL=”file://\LPSERVERUsers”]\LPSERVERUsers[/URL] DocumentsDoctors”
Call MapDrive(sDriveLetter, strUNC)
‘# Create shortcut:
strLNKPath = strDesktopFolder
strLNKname = “Veterinarians”
strTarget = “explorer.exe”
strArguments = “/e,/root,” & sDriveLetter & “”
Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
‘# Mapping’s alias: (optional – remove ‘rem’ to activate this routine)
rem Call NameMapping(strLNKname)
‘———————————————————————–
‘ next mappings and shortcuts….
wscript.quitSub CreateShortcut(sFolder, sName, sTarget, sArgs)
With WshShell ‘(has a global scope)
With .CreateShortcut(sFolder &”” & sName &”.LNK”)
.TargetPath = sTarget
.Description = sName
.Arguments = sArgs
.IconLocation = “shell32.dll, 9”
.WindowStyle = 3
.WorkingDirectory = “.”
.Save
End With
End With
End Sub
Sub MapDrive(DriveLetter, Share)
On Error Resume Next
With objNetwork
.MapNetworkDrive DriveLetter, Share, False
End With
End Sub
Sub NameMapping(sAlias)
With oShell
.NameSpace(sDriveLetter).Self.Name = sAlias
End With
End Sub[/CODE][CODE]Const CSIDL_DESKTOP = &H10
Dim strLNKPath, strLNKname
Dim strTarget, strArguments
Dim sDriveLetter, strUNC
Dim objNetwork: set objNetwork = CreateObject(“WScript.Network”)
Dim WshShell: set WshShell = CreateObject(“WScript.Shell”)
Dim oShell: Set oShell = CreateObject(“Shell.Application”)
Dim oDesktop: Set oDesktopFolder = oShell.Namespace(CSIDL_DESKTOP)
Dim strDesktopFolder: strDesktopFolder = oDesktopFolder.Self.path
‘duplicate part between —- sDriveLetter = “Z:” strUNC = “[URL=”file://\serversharedfolder”]\serversharedfolder[/URL]” strLNKname = “Network Share 1”
‘
‘ Mapping 1
‘
‘# Map drive:
sDriveLetter = “N:”
strUNC = “[URL=”file://\LPSERVERUsers”]\LPSERVERUsers[/URL] DocumentsInventory”
Call MapDrive(sDriveLetter, strUNC)
‘# Create shortcut:
strLNKPath = strDesktopFolder
strLNKname = “Inventory”
strTarget = “explorer.exe”
strArguments = “/e,/root,” & sDriveLetter & “”
Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
‘# Mapping’s alias: (optional – remove ‘rem’ to activate this routine)
rem Call NameMapping(strLNKname)
‘
‘
‘ Mapping 2
‘
‘# Map drive:
sDriveLetter = “R:”
strUNC = “[URL=”file://\LPSERVERUsers”]\LPSERVERUsers[/URL] DocumentsReceptionists”
Call MapDrive(sDriveLetter, strUNC)
‘# Create shortcut:
strLNKPath = strDesktopFolder
strLNKname = “Receptionist”
strTarget = “explorer.exe”
strArguments = “/e,/root,” & sDriveLetter & “”
Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
‘# Mapping’s alias: (optional – remove ‘rem’ to activate this routine)
rem Call NameMapping(strLNKname)
‘
‘
‘ Mapping 2
‘
‘# Map drive:
sDriveLetter = “S:”
strUNC = “[URL=”file://\LPSERVERHPDigitalSender”]\LPSERVERHPDigitalSender[/URL]”
Call MapDrive(sDriveLetter, strUNC)
‘# Create shortcut:
strLNKPath = strDesktopFolder
strLNKname = “Scanner”
strTarget = “explorer.exe”
strArguments = “/e,/root,” & sDriveLetter & “”
Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
‘# Mapping’s alias: (optional – remove ‘rem’ to activate this routine)
rem Call NameMapping(strLNKname)
‘
‘
‘ Mapping 2
‘
‘# Map drive:
sDriveLetter = “V:”
strUNC = “[URL=”file://\LPSERVERUsers”]\LPSERVERUsers[/URL] DocumentsDoctors”
Call MapDrive(sDriveLetter, strUNC)
‘# Create shortcut:
strLNKPath = strDesktopFolder
strLNKname = “Veterinarians”
strTarget = “explorer.exe”
strArguments = “/e,/root,” & sDriveLetter & “”
Call CreateShortcut(strLNKPath, strLNKname, strTarget, strArguments)
‘# Mapping’s alias: (optional – remove ‘rem’ to activate this routine)
rem Call NameMapping(strLNKname)
‘
‘ next mappings and shortcuts….
wscript.quitSub CreateShortcut(sFolder, sName, sTarget, sArgs)
With WshShell ‘(has a global scope)
With .CreateShortcut(sFolder &”” & sName &”.LNK”)
.TargetPath = sTarget
.Description = sName
.Arguments = sArgs
.IconLocation = “shell32.dll, 9”
.WindowStyle = 3
.WorkingDirectory = “.”
.Save
End With
End With
End Sub
Sub MapDrive(DriveLetter, Share)
On Error Resume Next
With objNetwork
.MapNetworkDrive DriveLetter, Share, False
End With
End Sub
Sub NameMapping(sAlias)
With oShell
.NameSpace(sDriveLetter).Self.Name = sAlias
End With
End Sub[/CODE] -
AuthorPosts
You must be logged in to reply to this topic.