- Copy internal post link
- Copy external post link
- Report article
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html
[content:35510]
VBS Skript nach Userlogin in CMD starten
ich habe an alle Admins hier mal eine Fachfrage.
Ich habe eine VBS Datei die nach dem Login des Users sämtliche Laufwerke mappen soll. Dieses wird auch durchgeführt. Derzeit ist es jedoch so, dass der User jedes Feld wie Username, Domain, Department etc mit Ok bestätigen muss. Gibt es die Möglichkeit das dieses Script nach dem Start in einem CMD Fenster abläuft ohne das der User etwas bestätigen muss. Am Ende sollte dann der User nur das Fenster schliessen müssen und fertig.
Wenn das Skipt als Beispiel nötig ist, dann bitte einfach Bescheid sagen.
Danke für die Antworten
Der Lord
Content-Key: 35510
Url: https://administrator.de/contentid/35510
Printed on: April 23, 2024 at 22:04 o'clock
- Comment overview - Please log in
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-142877
[content:35510#142877]
poste das Script einfach. Somit ist einfacher für alle!
Gruß
Dani
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-142883
[content:35510#142883]
' login.vbs
'
' Author: Lorderich
' Date: 29.06.2006
' Platform: Windows XP/2000
' Language: VBScript
' Purpose: Login script for Site local
'
' (c) 2004
'
' last change: 06.07.2005 06:04:40
'----------------------------------------------------------
Option Explicit
'On Error Resume Next
' Decleare the variable
Dim Debug
Dim strLoginScriptName
Dim objNetwork
Dim strComputerName, strUserName, strDomainName
Dim strDFSRoot
Dim strDepartment
' Defaults
' Debug Var - >0 Debug on, 0 Debug off
Debug = 0
strLoginScriptName = "Login Script für local"
' Netwerkumgebung auslesen
call GetNetworkEnvironment
'----------------------------------------------------------
' Begin Login Script
'----------------------------------------------------------
WScript.Echo "Starte: " & strLoginScriptName
Wscript.Echo "Computername : " & strComputerName
Wscript.Echo "Username : " & strUserName
Wscript.Echo "Domain : " & strDomainName
Wscript.Echo "Department : " & strDepartment
Wscript.Echo "DFS Root : " & strDFSRoot
Wscript.Echo "Delete all mappings"
DeleteAllMappings
Wscript.Echo "Map Network Drives"
'Map Users Homedrives
MapDrive "W:" , strDFSRoot & "profile\" & strUserName
'Map Drive all Domain Users
If IsMemberOf( "Domain Admins" ) Then
MapDrive "Z:" , strDFSRoot & "programme"
End If
'Map Drive all Domains Users
If IsMemberOf( "Domain Users" ) Then
MapDrive "Y:" , strDFSRoot & "musik"
End If
'Map Notes Profile Share and set the needed Registry Key
If IsMemberOf( "Domain Admins" ) Then
MapDrive "X:" , strDFSRoot & "data"
SetRegKeyNotes
End If
If IsMemberOf( "Domain Admins" ) Then
MapDrive "U:" , strDFSRoot & "backup"
SetRegKeyNotes
End If
'----------------------------------------------------------
' Sub GetNetworkEnvironment
'----------------------------------------------------------
Private Sub GetNetworkEnvironment
Dim objShell
Dim objNetwork, colNetDrives
'On Error Resume Next
' Defaults
Err.Clear
'Get Shell Object
Set objShell = CreateObject("wscript.shell")
'Get Network Object
Set objNetwork = CreateObject("Wscript.Network")
Do While objNetwork.UserName = ""
WScript.Sleep 250
Loop
strComputerName = objNetwork.computerName
strUserName = objNetwork.userName
strDomainName = objNetwork.userDomain
strDepartment = "local"
strDFSRoot = "\\local.domain\"
If Debug > 0 Then
Wscript.Echo "-- Computername : " & strComputerName
Wscript.Echo "-- Username : " & strUserName
Wscript.Echo "-- Domain : " & strDomainName
Wscript.Echo "-- Department : " & strDepartment
Wscript.Echo "-- DFS Root : " & strDFSRoot
End If
End Sub
'----------------------------------------------------------
' Function MapDrive (LW, UNC)
' LW: Laufwerk (K
' UNC: UNC Path \\server\share
'----------------------------------------------------------
Private Function MapDrive (Lw, Unc)
Dim objNetwork, colNetDrives
Dim bForce, bUpdateProfile
Dim N
On Error Resume Next
' Defaults
bForce = true
bUpdateProfile = true
Err.Clear
'Get Network Object
Set objNetwork = CreateObject("Wscript.Network")
Set colNetDrives = objNetwork.EnumNetworkDrives
If Debug > 0 Then Wscript.Echo "-- MapDrive(" & Lw & ", " & Unc & ")"
MapDrive = False
If colNetDrives.Count = 0 then
If Debug > 0 Then Wscript.Echo "-- No Network Drives to delete"
Else
For N = 0 To colNetDrives.count-1 Step 2
If Mid(colNetDrives.Item(N),1,1) = UCase(Mid(Lw,1,1)) Then
If Debug > 0 Then Wscript.Echo "-- Delete Network Drives[" & N & "] : " & colNetDrives.Item(N)
objNetwork.RemoveNetworkDrive colNetDrives.Item(N), bForce, bUpdateProfile
If Err.Number <> 0 Then Wscript.Echo "-- Error deleting: [" & Hex(Err.Number) & "] " & Err.Description
End If
Next
End If
Wscript.Echo "map : " & Lw & " -> " & Unc
objNetwork.MapNetworkDrive Lw, Unc
If Err.Number <> 0 Then
MapDrive = False
Wscript.Echo "-- Error mapping : [" & Hex(Err.Number) & "] " & Err.Description
Else
MapDrive = True
End If
End Function
'----------------------------------------------------------
' Function IsMemberOfMapDrive (LW, UNC, GroupName)
' LW:
' UNC:
' GroupName:
'----------------------------------------------------------
Private Function IsMemberOfMapDrive (Lw, Unc, GroupName)
Dim objNetwork, colNetDrives
Dim objWinNT, objGroup
Dim strADSPath
Dim bForce, bUpdateProfile
Dim N
'On Error Resume Next
' Defaults
bForce = true
bUpdateProfile = true
IsMemberOfMapDrive = False
Err.Clear
If Debug > 0 Then Wscript.Echo "-- IsMemberOfMapDrive(" & Lw & ", " & Unc & ", " & GroupName & ")"
'Get Network Objects
Set objNetwork = CreateObject("Wscript.Network")
Set colNetDrives = objNetwork.EnumNetworkDrives
'Get ADSI Objects
strADSPath = "WinNT:" & strDomainName & "/" & strUserName
Set objWinNT = GetObject ( strADSPath )
If colNetDrives.Count = 0 then
If Debug > 0 Then Wscript.Echo "-- No Network Drives to delete"
Else
For N = 0 To colNetDrives.count-1 Step 2
If Mid(colNetDrives.Item(N),1,1) = UCase(Mid(Lw,1,1)) Then
If Debug > 0 Then Wscript.Echo "-- Delete Network Drives[" & N & "] : " & colNetDrives.Item(N)
objNetwork.RemoveNetworkDrive colNetDrives.Item(N), bForce, bUpdateProfile
If Err.Number <> 0 Then Wscript.Echo "-- Error deleting: [" & Hex(Err.Number) & "] " & Err.Description
End If
Next
End If
'On Error Resume Next
For Each objGroup In objWinNT.Groups
If Debug > 0 Then Wscript.Echo "-- member of: " & objGroup.Name
If InStr(objGroup.Name, GroupName) Then
Wscript.Echo "map : " & Lw & " -> " & Unc & " (" & GroupName & ")"
objNetwork.MapNetworkDrive Lw, Unc
If Err.Number <> 0 Then
IsMemberOfMapDrive = False
Wscript.Echo "-- Error mapping : [" & Hex(Err.Number) & "] " & Err.Description
Exit Function
End If
IsMemberOfMapDrive = True
Exit Function
End If
Next
End Function
'----------------------------------------------------------
' Function DeleteAllMappings ()
'
'----------------------------------------------------------
Private Function DeleteAllMappings ()
'On Error Resume Next
Dim objNetwork, colNetDrives
Dim bForce, bUpdateProfile
Dim N
' Defaults
bForce = true
bUpdateProfile = true
DeleteAllMappings = False
Err.Clear
'Get Objects
Set objNetwork = CreateObject("Wscript.Network")
Set colNetDrives = objNetwork.EnumNetworkDrives
If colNetDrives.Count = 0 then
If Debug > 0 Then Wscript.Echo "-- No Network Drives to delete"
Else
For N = 0 To colNetDrives.count-1 Step 2
If Debug > 0 Then Wscript.Echo "-- Delete Network Drive[" & N & "] : " & colNetDrives.Item(N)
objNetwork.RemoveNetworkDrive colNetDrives.Item(N), bForce, bUpdateProfile
Next
End If
If Err.Number <> 0 Then
DeleteAllMappings = False
Wscript.Echo "-- Error delete mappings : [" & Hex(Err.Number) & "] " & Err.Description
Else
DeleteAllMappings = True
End If
End Function
'----------------------------------------------------------
' Function IsMemberOf (GroupName)
' LW:
' UNC:
'----------------------------------------------------------
Private Function IsMemberOf (GroupName)
Dim objNetwork
Dim objWinNT, objGroup
Dim strADSPath
'On Error Resume Next
' Defaults
IsMemberOf = False
Err.Clear
'Get Network Objects
Set objNetwork = CreateObject("Wscript.Network")
'Get ADSI Objects
strADSPath = "WinNT:" & strDomainName & "/" & strUserName
Set objWinNT = GetObject ( strADSPath )
'On Error Resume Next
For Each objGroup In objWinNT.Groups
If InStr(objGroup.Name, GroupName) Then
If Debug > 0 Then Wscript.Echo "-- member of: " & objGroup.Name & " : True"
If Err.Number <> 0 Then
IsMemberOf = False
Wscript.Echo "-- Error IsMemberOf : [" & Hex(Err.Number) & "] " & Err.Description
End If
IsMemberOf = True
Exit Function
End If
Next
End Function
'----------------------------------------------------------
' Function AddWindowsPrinter (unc)
'
'----------------------------------------------------------
Private Function AddWindowsPrinter (unc)
Dim objNetwork
'Get Network Object
Set objNetwork = CreateObject("WScript.Network")
objNetwork.AddWindowsPrinterConnection unc
WScript.Echo "Connected Printer: " & unc
End Function
'---------------------------------------------------------------------
' Function CreateDesktopLink (LinkName, Path, Description, WorkingDir)
'
'---------------------------------------------------------------------
Private Function CreateDesktopLink (LinkName, Path, Description, WorkingDir)
Dim WshShell
Dim DesktopFolder
Dim FileShortcut
set WshShell = WScript.CreateObject("WScript.Shell")
DesktopFolder = WshShell.SpecialFolders("Desktop")
set FileShortcut = WshShell.CreateShortcut(DesktopFolder & LinkName)
FileShortcut.TargetPath = Path
FileShortcut.Description = Description
FileShortcut.WorkingDirectory = WorkingDir
FileShortcut.Save
End Function
'----------------------------------------------------------------------
' Function CopyFoldersToAppData (SourcePath)
'
'----------------------------------------------------------------------
Private Function CopyFoldersToAppData (SourcePath)
Dim objShell
Dim objFolder
Dim ParentFolder
Const FOF_CREATEPROGRESSDLG = &H0&
Const APPLICATION_DATA = &H1a&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(APPLICATION_DATA)
objFolder.CopyHere SourcePath , FOF_CREATEPROGRESSDLG
End Function
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-143017
[content:35510#143017]
Gruß
Biber
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-143020
[content:35510#143020]
ich danke Euch.
Habe einen netten Hinweis eines Kollegenüberlesen
Aber jetzt läuft das ganze
Danke an alle
Der Lord
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-143388
[content:35510#143388]
irgendwie geht das ganze nur wenn ich es per cmd aufrufe.
Wie übergebe ich das in eine GPO. Wenn ich das Loginscript per UNC Pfad angebe, dann müsste doch unter sciptparametern nur folgendes stehen:
Loginskript \\uncpfad\freigabelogin.vbs
Skriptparameter: cscript //nologo
Oder?
Der Lord
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-143528
[content:35510#143528]
gibt es die Möglichkeit per GPO allen System in der Domöne zu sagen, dass Sie eine Datei mit der Endung .vbs immer mit cscript.exe öffnen sollen?
Der Lord
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-143584
[content:35510#143584]
ich fürchte, da musst Du selbst was basteln.
Es gibt bei der CScript.exe einen Parameter
CScript //H:CScript Ändert den Standardskripthost auf CScript.exe um
...das heißt, wenn Du das EINmalig in irgendeinem Startup-/Loginscript der Clients aufrufen lässt ODER wenn Du die oben stehende login.vbs aus einer Login.bat aufrufst, die diese Zeile enthält, dann sollte es klappen.
[Theoretisch. Gib also bitte Rückmeldung, wenn es tut/nicht tut.]
Gruß
Biber
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-144555
[content:35510#144555]
danke für deinen Hinweis. Ich habe jetzt einfach eine Bat Datei zusammengebastelt, die jedem Rechner der neu in der Dömane ist, dass VBS Dateien nicht mit Wscript aufgerufen werden, sondern mit CScript.exe.
Einfache bat Datei mit dem Befehl: CScript //H:CScript
Feierabend und fertig.
Das noch in ne GPO gezwängt klappt perfekt.
Der Lord
- Copy internal comment link
- Copy external comment link
- To the beginning of the comments
https://administrator.de/forum/vbs-skript-nach-userlogin-in-cmd-starten-35510.html#comment-144565
[content:35510#144565]
...wenn Du jetzt noch den Beitrag auf "Gelöst" setzen könntest, wäre ich dankbar.
Sieht ja einfach nicht gut aus, so viele ungelöste Fragen...
Gruß
Biber