ICH GLAUB ICH HABS !
Code
Dim WshShell,Fs,wshnetwork
Dim arrLoginScript(7,5) '8 Zeilen (0-7) und 6 Spalten (0-5)
Dim strInfo1,strInfo2
Dim i
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set Fs = CreateObject("Scripting.FileSystemObject")
set wshnetwork = WScript.CreateObject("WScript.Network")
arrLoginScript(0,0) = "0.0.0.0"
arrLoginScript(0,1) = "NAME1"
arrLoginScript(0,2) = "I:"
arrLoginScript(0,3) = "Ein"
arrLoginScript(0,4) = ""
arrLoginScript(0,5) = ""
arrLoginScript(1,0) = "0.0.0.0"
arrLoginScript(1,1) = "NAME2"
arrLoginScript(1,2) = "K:"
arrLoginScript(1,3) = "Ein"
arrLoginScript(1,4) = ""
arrLoginScript(1,5) = ""
arrLoginScript(2,0) = "0.0.0.0"
arrLoginScript(2,1) = "NAME3"
arrLoginScript(2,2) = "R:"
arrLoginScript(2,3) = "Aus"
arrLoginScript(2,4) = ""
arrLoginScript(2,5) = ""
wshshell.popup "Willkommen ich heisse Gold_Monster." & vbCRLF & vbCRLF & _
"Es werden jetzt alle notwendigen Netzwerkressourcen erstellt." & vbCRLF & vbCRLF & _
for i = lbound(arrLoginScript,1) to ubound(arrLoginScript,1)
If arrLoginScript(i,3) = "Ein" Then
'Prüfen ob Laufwerk existiert und verbinden
err.clear
on error resume next
If Fs.DriveExists(arrLoginScript(i,2)) Then
WshNetwork.RemoveNetworkDrive arrLoginScript(i,2)
If err.number <> 0 Then
arrLoginScript(i,4) = "No Remove"
arrLoginScript(i,5) = vbCRLF & "Fehler 1 = Ressource nicht verfügbar: " & arrLoginScript(i,1) & " auf " & "''" & arrLoginScript(i,0) & "''" & " (" & arrLoginScript(i,2) & ")"
Else
wshnetwork.MapNetworkDrive arrLoginScript(i,2), "\\" & arrLoginScript(i,0) & "\" & arrLoginScript(i,1)
If err.number = 0 Then
arrLoginScript(i,5) = ""
Else
arrLoginScript(i,4) = "No Connect"
arrLoginScript(i,5) = vbCRLF & "Fehler 2 = Ressource nicht verfügbar: " & arrLoginScript(i,1) & " auf " & "''" & arrLoginScript(i,0) & "''" & " (" & arrLoginScript(i,2) & ")"
End If
End If
Else
wshnetwork.MapNetworkDrive arrLoginScript(i,2), "\\" & arrLoginScript(i,0) & "\" & arrLoginScript(i,1)
If err.number = 0 Then
arrLoginScript(i,5) = ""
Else
arrLoginScript(i,4) = "No Connect"
arrLoginScript(i,5) = vbCRLF & "Fehler 2 = Ressource nicht verfügbar: " & arrLoginScript(i,1) & " auf " & "''" & arrLoginScript(i,0) & "''" & " (" & arrLoginScript(i,2) & ")"
End If
End If
err.clear
Else
arrLoginScript(i,5) = ""
End If
next
'Fehlerbehandlungsroutine
If arrLoginScript(0,4) = "No Connect" or _
arrLoginScript(1,4) = "No Connect" or _
arrLoginScript(2,4) = "No Connect" or _
arrLoginScript(3,4) = "No Connect" or _
arrLoginScript(4,4) = "No Connect" or _
arrLoginScript(5,4) = "No Connect" or _
arrLoginScript(6,4) = "No Connect" or _
arrLoginScript(7,4) = "No Connect" or _
arrLoginScript(0,4) = "No Remove" or _
arrLoginScript(1,4) = "No Remove" or _
arrLoginScript(2,4) = "No Remove" or _
arrLoginScript(3,4) = "No Remove" or _
arrLoginScript(4,4) = "No Remove" or _
arrLoginScript(5,4) = "No Remove" or _
arrLoginScript(6,4) = "No Remove" or _
arrLoginScript(7,4) = "No Remove" _
Then
strInfo1 = "Es gab Probleme bei der Erstellung von Netzwerkressoucen!" & vbCRLF & vbCRLF & _
"Notieren Sie sich die Fehlermeldungen." & vbCRLF
strInfo2 = "Anmerkungen:" & vbCRLF & _
"Fehler 1 bedeutet - Der Laufwerksbuchstabe existiert bereits und kann nicht gelöscht werden." & vbCRLF & _
"Fehler 2 bedeutet - Die Verbindung zum Server konnte nicht hergestellt werden." & vbCRLF & vbCRLF & _
"Wenden Sie sich an Gold_Monster."
MsgBox strInfo1 & arrLoginScript(0,5) & _
arrLoginScript(1,5) & _
arrLoginScript(2,5) & _
arrLoginScript(3,5) & _
arrLoginScript(4,5) & _
arrLoginScript(5,5) & _
arrLoginScript(6,5) & _
arrLoginScript(7,5) & _
vbCRLF & vbCRLF & strInfo2 ,64,"Info" & wscript.quit
Set Fs=nothing
Set WshShell=nothing
set wshnetwork=nothing
Else
wshshell.popup "Alle Netzwerkressourcen wurden erfolgreich erstellt!" & vbCRLF ,3,"Info"
Set Fs=nothing
Set WshShell=nothing
set wshnetwork=nothing
End If