Avatar billede XenoBIT78 Nybegynder
21. juni 2010 - 04:59 Der er 1 løsning

VBs Logon script

Hejsa :)

Jeg har en lille server (w2k8r2) hvor jeg kører et vbs logon script som mapper nogle netværksstier til forskellige drev osv..  men kunne godt tænke mig at når jeg logge på selve serveren at den ikke laver de mappings da drevene jo er på serveren.  altså en måde at skippe mappings ud fra hvilken klient der logges på..  Nogen der lige kan hjælpe med det ?

Scriptet:

Option Explicit

Dim objNetwork, objShell, strUserName
Dim CheckDrive, AlreadyConnected, intDrive
Dim objUNC, strNewName


Dim strDriveLetter1, strRemotePath1, strUser1, strPassword1, strProfile1, strNewName1
Dim strDriveLetter2, strRemotePath2, strUser2, strPassword2, strProfile2, strNewName2
Dim strDriveLetter3, strRemotePath3, strUser3, strPassword3, strProfile3, strNewName3
Dim strDriveLetter4, strRemotePath4, strUser4, strPassword4, strProfile4, strNewName4
Dim strDriveLetter5, strRemotePath5, strUser5, strPassword5, strProfile5, strNewName5
Dim strDriveLetter6, strRemotePath6, strUser6, strPassword6, strProfile6, strNewName6
Dim strDriveLetter7, strRemotePath7, strUser7, strPassword7, strProfile7, strNewName7
Dim strDriveLetter8, strRemotePath8, strUser8, strPassword8, strProfile8, strNewName8


Set objNetwork = WScript.CreateObject("WScript.Network")
strUserName = objNetwork.UserName


' Series
strDriveLetter8 = "v:"
strRemotePath8 = "\\server\series"
'strUser8 = "username"
'strPassword8 = "password"
strProfile8 = "false"
strNewName8 = "series"


' Privat
strDriveLetter7 = "s:"
strRemotePath7 = "\\server\users"
'strUser7 = "username"
'strPassword7 = "password"
strProfile7 = "false"
strNewName7 = "privat"


' diverse
strDriveLetter6 = "x:"
strRemotePath6 = "\\server\diverse"
'strUser6 = "username"
'strPassword6 = "password"
strProfile6 = "false"
strNewName6 = "diverse"

' iso
strDriveLetter5 = "w:"
strRemotePath5 = "\\server\iso"
'strUser5 = "username"
'strPassword5 = "password"
strProfile5 = "false"
strNewName5 = "iso"

' movies
strDriveLetter4 = "u:"
strRemotePath4 = "\\server\movies"
'strUser4 = "username"
'strPassword4 = "password"
strProfile4 = "false"
strNewName4 = "movies"

' install
strDriveLetter1 = "y:"
strRemotePath1 = "\\server\install"
'strUser1 = "username"
'strPassword1 = "password"
strProfile1 = "false"
strNewName1 = "install"

' downloads
strDriveLetter2 = "z:"
strRemotePath2 = "\\server\downloads"
'strUser2 = "username"
'strPassword2 = "password"
strProfile2 = "false"
strNewName2 = "downloads"

' musik
strDriveLetter3 = "t:"
strRemotePath3 = "\\server\musik"
'strUser3 = "username"
'strPassword3 = "password"
strProfile3 = "false"
strNewName3 = "musik"


Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
Set CheckDrive = objNetwork.EnumNetworkDrives()
On Error Resume Next
AlreadyConnected = False
For intDrive = 0 To CheckDrive.Count - 1 Step 2
If CheckDrive.Item(intDrive) =strDriveLetter _
Then AlreadyConnected =True
Next


If AlreadyConnected = True then
objNetwork.RemoveNetworkDrive strDriveLetter
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1, strProfile1, strUser1, strPassword1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2, strProfile2, strUser2, strPassword2
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3, strProfile3, strUser3, strPassword3
objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4, strProfile4, strUser4, strPassword4
objNetwork.MapNetworkDrive strDriveLetter5, strRemotePath5, strProfile5, strUser5, strPassword5
objNetwork.MapNetworkDrive strDriveLetter6, strRemotePath6, strProfile6, strUser6, strPassword6
objNetwork.MapNetworkDrive strDriveLetter7, strRemotePath7 & "\" & strUserName, strProfile7, strUser7, strPassword7
objNetwork.MapNetworkDrive strDriveLetter8, strRemotePath8, strProfile8, strUser8, strPassword8

Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter1).Self.Name = strNewName1
objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2
objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3
objShell.NameSpace(strDriveLetter4).Self.Name = strNewName4
objShell.NameSpace(strDriveLetter5).Self.Name = strNewName5
objShell.NameSpace(strDriveLetter6).Self.Name = strNewName6
objShell.NameSpace(strDriveLetter7).Self.Name = strNewName7
objShell.NameSpace(strDriveLetter8).Self.Name = strNewName8

Else
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1, strProfile1, strUser1, strPassword1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2, strProfile2, strUser2, strPassword2
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3, strProfile3, strUser3, strPassword3
objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4, strProfile4, strUser4, strPassword4
objNetwork.MapNetworkDrive strDriveLetter5, strRemotePath5, strProfile5, strUser5, strPassword5
objNetwork.MapNetworkDrive strDriveLetter6, strRemotePath6, strProfile6, strUser6, strPassword6
objNetwork.MapNetworkDrive strDriveLetter7, strRemotePath7 & "\" & strUserName, strProfile7, strUser7, strPassword7
objNetwork.MapNetworkDrive strDriveLetter8, strRemotePath8, strProfile8, strUser8, strPassword8

Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter1).Self.Name = strNewName1
objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2
objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3
objShell.NameSpace(strDriveLetter4).Self.Name = strNewName4
objShell.NameSpace(strDriveLetter5).Self.Name = strNewName5
objShell.NameSpace(strDriveLetter6).Self.Name = strNewName6
objShell.NameSpace(strDriveLetter7).Self.Name = strNewName7
objShell.NameSpace(strDriveLetter8).Self.Name = strNewName8

End if

WScript.Quit

(det kunne måske laves bedre end det jeg har lavet men ved det ikke, har ikke så fandens meget styr på VBS)

Alt hjælp vil være meget velkommen :)

-XenoBIT78
Avatar billede XenoBIT78 Nybegynder
22. juni 2010 - 22:10 #1
Fandt Selv Ud af det...

If objNetwork.ComputerName="SERVER" Then
'do nothing
Else

:)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester