Sorry
Quelle:
www.eknori.deDie Klasse remoteConsole ermöglicht das Absenden von Konsolenkommandos über Lotus Script.
Als Beispiel hier der Befehl "sh user", der die momentan am Server angemeldeten Personen auflistet
Sub Click(Source As Button)
Dim exec As String
Dim dummy As Variant
' hier den eigenen Server eintragen
Dim remConsole As New RemoteConsole ( "IhrServer" )
' welche Konsolenkommando ??
exec = "sh user"
'kein Kommando angegeben, dann beenden
If exec = "" Then
Exit Sub
Else
' Kommando ausführen
dummy = remConsole.Execute(exec)
' Rückgabewert steht in dummy
Msgbox dummy
End If
End Sub
Den folgenden Code in den Deklarationsteil eines Buttons, Agenten oder einer Scriptbibliothek kopieren
Declare Function NSFRemoteConsole Lib "NNotes.dll" Alias "NSFRemoteConsole" (Byval Server As String, Byval cmd As String, ret As Long) As Long
Declare Function OSLockObject Lib "NNotes.dll" Alias "OSLockObject" (Byval Handle) As String
Declare Sub OSUnlockObject Lib "NNotes.dll" Alias "OSUnlockObject" (Byval Handle)
Declare Sub OSMemFree Lib "NNotes.dll" Alias "OSMemFree" (Byval Handle)
Class remoteConsole
Private IsError As Variant
Private rc As Integer
Private hBuffer As Long
Private Server As String
Private Command As String
Private Result As String
Sub New(inpServer As String)
Dim server As New NotesSession
If inpServer = "" Then
Me.IsError = True
Else
Me.server=inpServer
Me.IsError = False
End If
End Sub
Function Execute(inpCommand As String) As String
If Me.Server = "" Then
Exit Function
End If
If inpCommand = "" Then
Me.execute="You must specify a command"
Me.iserror = True
Exit Function
Else
Me.command = inpCommand
End If
Me.rc = NSFRemoteConsole(Me.server, Me.command, hBuffer)
If Me.rc <> 0 Then
Me.iserror = True
Me.result="Error returned " & _
" from console [" & Cstr(rc) & "]"
Else
Me.result = OSLockObject(hBuffer)
Call OSUnlockObject(hBuffer)
Call OSMemFree(hBuffer)
Me.Iserror = False
End If
Me.execute = Me.result
End Function
End Class