Deltaboy Script Base (DSB) © Torben Jørgensen
   
VBS  VBA Word  VBA Excel  VBA Access  VB 6.0  Registry key  Java Script  CMD  ASP 
 

  
Add Template to rightclick
AddGlobalGroupToLocal
AddToLocalAdm
AddWindowsPrinter
ArangeWindows
Caluclate
ChPermisionOnFiles
Create entry in Saplogon.ini
DisarmScreensaver
Enumerate computer accounts
enumerate domains
Enumerate groups
Enumerate sorftware
Enumerate user accounts
Environment var
Get WSH Version
GetPCName
GetUserName
GroupMembership.vbs
Identify OS
ListAddRemovePrograms
Logoff
MapDrv
MonitorApp
Progress_bar
Read in file
ReadDiffOSRegKey
Reboot
Require a Password Change
SendMail
SetPassword
Start_serviceses
Track Script In Browser
UnlockUserAccount
UserIsLogedOnPCName
Write to Event Log
  Home    Logbook    Photos    Links    Tools    Scripts 

Create entry in Saplogon.ini

Creates a new entry in SAPLogon.ini
Set objFSO = CreateObject("Scripting.FileSystemObject") 
 
Dim objfso, SourceFile, TargetFile, txtContent, TextLine, StrSection 
Const ForReading = 1, ForWriting = 2, TristateTrue = -1 
 
Function GetNextEntryNo(strFile) 
  Dim objFile, IntCount, IntCurrent 
  If objFSO.FileExists(strFile) Then 
    Set objFile = objFSO.OpenTextFile(strFile, ForReading) 
    Do While objFile.AtEndOfStream <> True 
      TextLine = objFile.ReadLine 
      If Left(TextLine, 4) = "Item" Then 
        If IsNumeric(Mid(TextLine, 5, 2)) Then 
          IntCurrent = int(Mid(TextLine, 5, 2)) 
          if intCurrent > IntCount Then 
            IntCount = intcurrent 
          End if 
        Else 
          IntCurrent = int(Mid(TextLine, 5, 1)) 
          if intCurrent > IntCount Then 
            IntCount = intCurrent 
          End If 
        End if 
      End If 
    Loop 
  objFile.Close 
  GetNextEntryNo = IntCount  
  End If 
End Function 
 
Function TextExists(strFile, strSearch) 
  Dim strContents, CheckText, objFile 
  CheckText = 0 
  If objFSO.FileExists(strFile) Then 
    Set objFile = objFSO.OpenTextFile(strFile, ForReading) 
    strContents = objFile.ReadAll 
    objFile.Close 
    If InStr(strContents, strSearch) > 0 Then 
      TextExists = True 
    Else 
      TextExists = False 
    End If 
  End If 
End Function 
 
if not objfso.FileExists("c:\windows\saplogon.ini") or TextExists("c:\windows\saplogon.ini", "myserver.local") then  
  wscript.quit 
End if 
 
IntCountItems = GetNextEntryNo("c:\windows\saplogon.ini") 
 
Set SourceFile = objfso.OpenTextFile("c:\windows\saplogon.ini", ForReading) 
Set TargetFile = objfso.OpenTextFile("c:\windows\saplogon.txt", ForWriting, True) 
 
Do While SourceFile.AtEndOfStream <> True 
  TextLine = SourceFile.ReadLine 
  TargetFile.WriteLine TextLine 
 
  if Left(TextLine, 1) = "[" then 
    StrSection = TextLine 
  End If 
 
  if Left(TextLine, 4 + Len(IntCountItems)) = "Item" & IntCountItems then 
    Select Case StrSection 
      Case "[RouterChoice]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=0" 
      Case "[Server]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=myserver.local" 
      Case "[Database]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=00" 
      Case "[System]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=3" 
      Case "[Description]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=T@is Production" 
      Case "[MSSysName]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=PT1" 
      Case "[SessManKey]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=-1" 
      Case "[SncChoice]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=-1" 
      Case "[Codepage]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=1100" 
      Case "[CodepageIndex]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=-1" 
      Case "[Origin]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=USEREDIT" 
      Case "[LowSpeedConnection]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=0" 
      Case "[Utf8Off]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=0" 
      Case "[EncodingID]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=DEFAULT_NON_UC" 
      Case "[ShortcutType]" 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=0" 
      Case Else 
        TargetFile.WriteLine "Item" & IntCountItems + 1 & "=" 
    End Select 
  End If 
Loop 
 
SourceFile.Close 
TargetFile.Close 
 
if objfso.FileExists("c:\windows\saplogon.old") Then 
  objfso.DeleteFile("c:\windows\saplogon.old") 
End If 
 
Set SourceFile=objfso.getfile("c:\windows\saplogon.ini")    
sname=SourceFile.name             
SourceFile.name=Left(sname,8) & ".old"  
set SourceFile=Nothing 
 
Set SourceFile=objfso.getfile("c:\windows\saplogon.txt")    
sname=SourceFile.name             
SourceFile.name=Left(sname,8) & ".ini"  
set SourceFile=Nothing			   


Bookmark this page Danmarks Meteorologiske institut Dansk Drageflyver Union Check out MySpace Looking for somthing?