---
title: "VBS logon script"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/166173-vbs-logon-script"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "greatest757"
published: "2007-11-07T09:31:00.000Z"
updated: "2007-11-07T09:31:00.000Z"
replies: 0
views: 401
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/166173-vbs-logon-script"
---

# VBS logon script

## #1 — greatest757, 2007-11-07T09:31Z

Hej

Jag har ett logonscript till Vista med Network map.
Jag skulle vilja att desa mappningar på nätvärks diskar är persistent.
Så att det finns där även när man inte är på nätet så att när man kör VPN och loggar in kopplar de upp sig igen.
Hur gör man det?

Så här ser det ut

If InGroup("HK_Alla") Then
  MapDrive "g:", "\\\\srv01-file\\gemensam" 
  MapDrive "h:", "\\\\srv02-file\\" & Username 
  MapDrive "m:", "\\\\srv03-file\\mallar" 
  MapDrive "p:", "\\\\srv04-file\\program" 
end If

Sedan ligger det visst en function i scriptet också
' Function:      MapDrive
' Arguments:     Drive Letter (with ":")
' Description:   Maps Share' mapping CANNOT exist already

Sub MapDrive( strDrive, strShare )
  'Declarations
  dim oDrives
  Dim Path
  If InStr(strShare,"\\") then     
    Path=strShare
  Else    
    Path="\\\\" & ShareSvr & "\\" & strShare
  End If
  ' Map drive
  On Error Resume Next
  WSHNetwork.MapNetworkDrive strDrive, Path
  ' End Sub result
  If Err.Number \<\> 0 Then WriteErr( strUserID & ": Mapping " & strDrive & " to " & Path & " " & Err.Description & " " & Now() )
End Sub

Tack 

Micke

Permalänk: https://www.webforum.nu/p/166173

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/166173-vbs-logon-script
