You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.8 KiB
Plaintext

'Eintragen einiger Punkte in FockeTools/Startup.ini
Option Explicit
Dim wshshell,fso,i,Fnct
Dim strPath,strSystemFolder,strWinFolder,strTempFolder
'----------------------------- Objekte erzeugen --------------------------------
Set wshshell = CreateObjectSafely("WScript.Shell")
Set fso = CreateObjectSafely("Scripting.FileSystemObject")
Set Fnct = CreateObjectSafely("Install.Functions")
'--------------------------- Standardpfade -------------------------------------
strPath = GetCurrentPath()
strSystemFolder = fso.GetSpecialFolder(1) & "\"
strWinFolder = fso.GetSpecialFolder(0) & "\"
strTempFolder = fso.GetSpecialFolder(2) & "\"
'------------------------------ Main -------------------------------------------
WriteToLog("Start")
'Dateinamen festlegen
Dim cstrStartupIni
cstrStartupIni = ExpandPath("%FOCKETOOLSDIR%","c:\FockeTools")
cstrStartupIni = cstrStartupIni & "\Startup.ini"
'Gibt es schon einen Eintrag?
' Wenn nicht, dann eintragen
Dim nIndex
If Not IniEntryExists("Change Access for pqi-Files") Then
WriteToLog("Change Access for pqi-Files")
nIndex = GetNextFreeIndex()
Call Fnct.SetIniString("Setup","Prg" & nIndex,"wscript.exe c:\FockeTools\PqiAccess.vbs",cstrStartupIni)
Call Fnct.SetIniString("Setup","Txt" & nIndex,"Change Access for pqi-Files",cstrStartupIni)
Call Fnct.SetIniString("Setup","Style" & nIndex,"6",cstrStartupIni)
Call Fnct.SetIniString("Setup","Delay" & nIndex,"65",cstrStartupIni)
End If
If Not IniEntryExists("Check Administrator logon") Then
WriteToLog("Check Administrator logon")
nIndex = GetNextFreeIndex()
Call Fnct.SetIniString("Setup","Prg" & nIndex,"wscript.exe c:\FockeTools\WarningAdmin.vbs",cstrStartupIni)
Call Fnct.SetIniString("Setup","Txt" & nIndex,"Check Administrator logon",cstrStartupIni)
Call Fnct.SetIniString("Setup","Style" & nIndex,"6",cstrStartupIni)
Call Fnct.SetIniString("Setup","Delay" & nIndex,"65",cstrStartupIni)
End If
If Not IniEntryExists("Delete temporary files") Then
WriteToLog("Delete temporary files")
nIndex = GetNextFreeIndex()
Call Fnct.SetIniString("Setup","Prg" & nIndex,"wscript.exe c:\FockeTools\DelTmpFiles.vbs",cstrStartupIni)
Call Fnct.SetIniString("Setup","Txt" & nIndex,"Delete temporary files",cstrStartupIni)
Call Fnct.SetIniString("Setup","Style" & nIndex,"6",cstrStartupIni)
Call Fnct.SetIniString("Setup","Delay" & nIndex,"65",cstrStartupIni)
End If
WriteToLog("End")
'------------------------------- Funktionen ------------------------------------
Function GetCurrentPath()
Dim l_strScriptName
Dim l_strTemp
l_strScriptName = WScript.ScriptFullName
l_strTemp = WScript.ScriptName
GetCurrentPath = Left(l_strScriptName, Len(l_strScriptName) - Len(l_strTemp))
End Function
Function ExpandPath(p_strEnvironment,p_strDefault)
Dim l_strTemp
l_strTemp = wshshell.ExpandEnvironmentStrings(p_strEnvironment)
If l_strTemp = p_strEnvironment Then
l_strTemp = p_strDefault
End If
ExpandPath = l_strTemp
End Function
'Hilfsfunktion zum Erzeugen von Objekten
'Ist die Erzeugung nicht m<>glich, wird das Skript beendet
Function CreateObjectSafely(p_strObject)
Dim i
i = 0
On Error Resume Next
Do
err.Clear
i = i+1
Set CreateObjectSafely = CreateObject(p_strObject)
WScript.Sleep 1000
Loop Until Err.Number = 0 OR i > 30
If Err.Number <> 0 Then
MsgBox "Unable to Create Object: " & p_strObject
WScript.Quit
End If
On Error Goto 0
End Function
'Wird der Eintrag in der StartupIni gefunden?
' Verglichen werden die Anzeigetexte
Function IniEntryExists(p_strEntry)
Dim strCurrentText
Dim bEntryFound
If p_strEntry = "" Then
bEntryFound = False
Else
Dim i
i = 0
do
i = i+1
strCurrentText = Fnct.GetIniString("Setup","Txt" & i,cstrStartupIni)
if strCurrentText = p_strEntry Then
bEntryFound = true
End If
'MsgBox strCurrentText
loop Until strCurrentText = "" Or bEntryFound
End If
IniEntryExists = bEntryFound
End Function
'Sucht den n<>chsten freien Index f<>r einen Neueintrag
Function GetNextFreeIndex
Dim strCurrentText
Dim i
i = 0
do
i = i+1
strCurrentText = Fnct.GetIniString("Setup","Txt" & i,cstrStartupIni)
loop Until strCurrentText = ""
GetNextFreeIndex = i
End Function
'------------------------------ Sub -------------------------------------------
Sub WriteToLog(p_strMessage)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim strLineToWrite
strLineToWrite = WScript.ScriptName & " -- " & p_strMessage
Dim strLogFile
strLogFile = ExpandPath("%SERVICEPACK_LOG%","c:\fockeservicepack.log")
' msgbox sLine & LogFile
Dim FileObject
if fso.FileExists(strLogFile) then
set FileObject = fso.OpenTextFile( strLogFile,ForAppending,false,0)
else
set FileObject = fso.OpenTextFile( strLogFile,ForWriting, true,0)
end if
FileObject.WriteLine(strLineToWrite)
FileObject.Close
set FileObject=nothing
End Sub