retz12
Goto Top

vbs Login-Script IE-Fenster schließen verhindern

Ich habe ein Login-Script, diese sämtliche Befehle wie Netzlaufwerk mappen, Drucker mappt, usw.
Als Ausgabe öffnet sich eine IE Seite wo angezeigt wird, was erfolgreich ausgeführt wurde.
Ich möchte jetzt, dass man das IE-Fenster nicht schließen kann. Es soll nach der angegeben Zeit selbst schließen.
Es sollte das "X" in der Leiste oben weg sein. Wie kann man das realisieren.

On Error Resume Next

' *** Initialze objects ***  
Set WSHNetwork = WScript.CreateObject("WScript.Network")  
Set WSHShell = WScript.CreateObject("WScript.Shell")  
Set objShell = CreateObject("Shell.Application")  
Set WSHFso = WScript.CreateObject("Scripting.FileSystemObject")  
Set MSIE = WScript.CreateObject("InternetExplorer.Application")  
Set FileSystem = CreateObject("Scripting.FileSystemObject")  
Set fs = CreateObject("Scripting.filesystemobject")  
Set net = CreateObject("WScript.Network")  


' *** Get environment information ***  
OS 						= WSHShell.ExpandEnvironmentStrings("%OS%")  
WINDIR 					= WSHShell.ExpandEnvironmentStrings("%WINDIR%")  
PROGRAMDIR 				= WSHShell.ExpandEnvironmentStrings("%ProgramFiles%")  
USERPROFILE 			= WSHShell.ExpandEnvironmentStrings("%USERPROFILE%")  
WSHVer 					= WScript.Version
WORKSTATION 			= WSHNetwork.ComputerName
USERDOMAIN 				= WSHNetwork.UserDomain
USERDNSDOMAIN 			= WSHShell.ExpandEnvironmentStrings("%USERDNSDOMAIN%")  
LOGONSERVER				= LCase(WSHShell.ExpandEnvironmentStrings("%LOGONSERVER%") & "." & USERDNSDOMAIN)  
LOGONSERVER_NFQDNS 		= LCase(WSHShell.ExpandEnvironmentStrings("%LOGONSERVER%")) '*** NOT Ffull qualified DNS (=WINS-Notation "\\Servername") ***  
NETLOGON_DIR 			= WSHShell.ExpandEnvironmentStrings("%LOGONSERVER%") + "\NETLOGON\"  

While USERNAME = ""  
	USERNAME = WSHNetwork.UserName		' Wird solange ausgeführt, bis der User ermittelt ist.  
Wend


' *** IE-Ausgabe vorbereiten ***  
SetupMSIE()	' IE einstellen für das Anzeige Fenster.  

'*** Ausgabe Logo  
MSIE.Document.Write "<HTML><TITLE>" & USERDOMAIN & " Domain-Initialisierung für " & UCase(USERNAME) & "</TITLE>" &_  
		    "<BODY bgcolor=#ffffff>" &_  
		    "<FONT FACE=ARIAL size='-1'>" &_  
		    "<table><tr><td align='left'><IMG SRC='" & NETLOGON_DIR & "images\logos\logo.bmp' WIDTH='50%'></td></tr></table><BR>" &_  
		    "<HR>"  

' *** Ausgabe Willkommensmeldung  
Welcome()


' **************************************************************************  
' *************************** Functions and Subs ***************************  
' **************************************************************************  


' **********************************************  
' * Funktion:		Sub Welcome  
' * Beschreibung:	Gibt die Willkommensmeldung aus.  
' * Parameter:		<keine>  
' * Rückgabe:		<keine>  
' **********************************************  
Sub Welcome()
	On Error Resume Next
	
	MSIE.Document.Write "<B>Guten "  
	
	If Hour(Now) < 12 Then
		MSIE.Document.Write "Morgen"  
	ElseIf Hour(Now) < 17 Then
		MSIE.Document.Write "Tag"  
	Else
		MSIE.Document.Write "Abend"  
	End If
	
	MSIE.Document.Write " " & UCase(USERNAME) & " und willkommen in " & UCase(USERDOMAIN) & "!</B>"  

	MSIE.Document.Write "<p>Ihr Logon-Server ist " & UCase(LOGONSERVER) & ".</p>"  

	If Err.Number <> 0 Then
		Err.Clear
	End If
End Sub

' **********************************************  
' * Funktion:		Sub TimeSync  
' * Beschreibung:	Synchronisiert die Systemzeit mit dem Timeserver  
' * Parameter:		<keine>  
' * Rückgabe:		<keine>  
' **********************************************  

' *** Synchronisation der Systemzeit ***  
TimeSync()

Sub TimeSync()
	'On Error Resume Next  
	MSIE.Document.Write "<BR>- Synchronisation der Systemzeit..."  
	WSHShell.Run "w32tm.exe /resync", 0  
End Sub
MSIE.Document.Write "<b><font color=#00FF00>        erfolgreich</font></b>"  

' **********************************************  
' * Funktion:		Sub SetupMSIE  
' * Beschreibung:	Bereitet das Internet-Explorer-Fenster für die   
' *			Ausgabe während der Ausführung des Login-Scripts vor  
' * Parameter:		<keine>  
' * Rückgabe:		<keine>  
' **********************************************  

Sub SetupMSIE()
	On Error Resume Next
	MSIE.Navigate "About:Blank"  
	MSIE.ToolBar = False
	MSIE.StatusBar = False
	MSIE.Resizable = False
	MSIE.Center = True
	
	Do
	Loop While MSIE.Busy

	SWidth = MSIE.Document.ParentWindow.Screen.AvailWidth
	SHeight = MSIE.Document.ParentWindow.Screen.AvailHeight
	MSIE.Width = SWidth * 0.5
	MSIE.Height = SHeight * 0.8
	MSIE.Left = (SWidth - MSIE.Width)/2
	MSIE.Top = (SHeight - MSIE.Height)/2

	MSIE.Visible = True


	
	If Err.Number <> 0 Then
		Err.Clear
	End If
End Sub

' *** Fehlerbehandlung ***  
MSIE.Document.Write "<HR>"  
If NErr = 0 Then
	' *** Keine Fehler aufgetreten ***  
	MSIE.Document.Write "Die Domain-Initialsierung für " & USERNAME & " wurde <b>erfolgreich</b> abgeschlossen. <br> <b>Unternehmen</b> wünscht einen schönen Tag."  
Else
	MSIE.Document.Write "<font color=#FF0000>Während der Domain-Initialisierung sind <b>Fehler</b> aufgetretten. Bitte informieren Sie Ihren Administrator.</font>"  
End If

MSIE.Document.Write "</p></FONT></BODY></HTML>"  
WScript.Sleep(50000) 	' *** Warten, damit Ausgabe gelesen werden kann ***  
MSIE.Quit		' *** Fenster zu! ***  
WScript.Quit		' *** Ende des Domain-Initialisierungs-Scripts ***  

Content-Key: 117370

Url: https://administrator.de/contentid/117370

Ausgedruckt am: 28.03.2024 um 18:03 Uhr

Mitglied: Logan000
Logan000 03.06.2009 um 16:19:14 Uhr
Goto Top
Moin Moin

Als Ausgabe öffnet sich eine IE Seite wo angezeigt wird, was erfolgreich ausgeführt wurde.
Ich möchte jetzt, dass man das IE-Fenster nicht schließen kann. Es soll nach der angegeben Zeit selbst schließen.
Es sollte das "X" in der Leiste oben weg sein. Wie kann man das realisieren.
Das Problem hatte ich auch mal konnte es aber nicht wirklich lösen.
Mein Workaround war Mir eine Ausgabe funktion für die IE meldungen zu Schreiben und den gesammten HTML Text zu merken. Ist diese Ist diese Augabe Funtion auf einen Fehler gelaufen (weil der IE geschlossen wurde) wir der IE neu geöffnet und der gesammte text wieder angezeigt.

Sah etwa so aus (Ich habe deine Funktionen verwendet daher nicht getestet):
function ShowHTML(szText)
	on error resume next	
	Dim szHTML
       szHTML = szHTML & szText
       MSIE.Document.Write szText 
	if err.number <>0 then
		'msgbox err.number  
		err.clear
		call SetupMSIE()
		MSIE.Document.Write = szHTML
	end if
end function

Gruß L.
Mitglied: 78632
78632 03.06.2009 um 16:24:50 Uhr
Goto Top
Zitat von @retz12:

Es sollte das "X" in der Leiste oben weg sein. Wie kann man das realisieren.

Gar nicht, es sei denn, du sperrst die Tastatur. Ob das X angezeigt wird oder nicht, ist völlig egal. Den IE kann man auch anders schließen,
z. B. mit STRG-W oder ALT-F4
Mitglied: 76109
76109 03.06.2009 um 18:41:18 Uhr
Goto Top
Hallo retz12!

Ich würde die Ausgabe anstatt über den IE über Shell.Run machen.

Diese VB-Script schreibt als Beispiel farbigen Text in eine *HTA-Datei und zeigt diese am Ende an:
'Eine riesige HTML-Farbtabelle mit Namen, Hex-Werte und mit RGB-Werte sind hier zu sehen: 'http://www.farb-tabelle.de/de/farbtabelle.htm  

Option Explicit

Const WindowSize = "480, 320"  

Const BodyBG = "#FFFFFF"  

Const Red1 = "#FF0000"	'Farbwert als Hex  
Const Red2 = "red"		'Farbwert als Name  
Const Red3 = "rgb(255,0,0)"	'Farbwert als RGB(R,G,B) Byte-Dezimal 0-255  

Const DarkBlue = "#00008B"  
Const DarkGreen = "#006400"  
Const DarkOrange = "#EE7600"  
Const DarkMagenta = "#8B008B"  

Dim Fso, HtaFile, HtaPath

'Main Beg  

    Call OpenHtaFile
    
    Call WriteHtaFile("Textausgabe", Red1)  
    Call WriteHtaFile("Textausgabe", Red2)  
    Call WriteHtaFile("Textausgabe", Red3)  
    Call WriteHtaFile("Textausgabe", DarkBlue)  
    Call WriteHtaFile("Textausgabe", DarkGreen)  
    Call WriteHtaFile("Textausgabe", DarkOrange)  
    Call WriteHtaFile("Textausgabe", DarkMagenta)  

    Call ShowHtaFile	
 
    Wscript.Quit

'Main End  

Private Sub OpenHtaFile()
    Set Fso = CreateObject("Scripting.FileSystemObject")  
    HtaPath = Fso.GetParentFolderName(WScript.ScriptFullName) & "\Ausgabe.Hta"  
    Set HtaFile = Fso.CreateTextFile(HtaPath)

    With HtaFile
        .WriteLine "<html>"  
        .WriteLine "<head>"  
        .WriteLine "<title>Textausgabe</title>"  
        .WriteLine "<head>"  
        .WriteLine "<style type='text/css'>"  
        .WriteLine "body { font-family:Arial, Tahoma; font-size:14px; background-color:" & BodyBG & "; }"  
        .WriteLine "</style></head>"   
        .WriteLine "<body onLoad='window.resizeTo(" & WindowSize & ")'>"  
    End With
End Sub

Private Sub WriteHtaFile(ByRef Text, ByRef Color)
    HtaFile.WriteLine "<font color='" & Color & "'>" & Text & "</font><br>"  
End Sub

Private Sub ShowHtaFile()
    Dim Shell
    
    With HtaFile
        .WriteLine "</body>"  
        .WriteLine "</html>"  
        .Close
    End With
    
    Set Shell = CreateObject("Wscript.Shell")  

    Shell.Run HtaPath, 1, True

    Fso.DeleteFile HtaPath
End Sub

Alternativ das gleiche als *.HTA-Script inklusive VB-Script:
<html>
<head>
<title>Textausgabe</title>
<HTA:APPLICATION 
     ID="objTextAusgabe"  
     APPLICATIONNAME="Text"  
     SCROLL="auto"  
     SINGLEINSTANCE="yes">  
</head>
<style type='text/css'>  
     body { font-family:Arial, Tahoma; font-size:14px; background-color:#F0F0F0; }
</style>
</head> 
       
<SCRIPT LANGUAGE="VBScript">  

    Const WindowWidth = 480
    Const WindowHeight = 320

    Const Red = "#FF0000"  
    Const DarkBlue = "#00008B"  
    Const DarkGreen = "#006400"  
    Const DarkOrange = "#EE7600"  
    Const DarkMagenta = "#8B008B"  

    Sub Window_OnLoad 	'Main Beg  

        window.resizeTo WindowWidth, WindowHeight

    	Call WriteBodyText("Textausgabe", Red)  
    	Call WriteBodyText("Textausgabe", DarkBlue)  
    	Call WriteBodyText("Textausgabe", DarkGreen)  
    	Call WriteBodyText("Textausgabe", DarkOrange)  
    	Call WriteBodyText("Textausgabe", DarkMagenta)  
	
    End Sub		'Main End  

    Sub WriteBodyText(Byref Text, Byref Color)
    	TextList.InnerHTML = TextList.InnerHTML & "<font color='" & Color & "'>" & Text & "</font><br>"  
    End Sub

</SCRIPT>

<body><span id = "TextList"></span></body>  
</html>

Vielleicht hilft Dir das ja weiter.

Gruß Dieter