SendConsoleCommand used by agent RunOnServer

I am have an agent that sends command on console using"SendConsoleCommand" and put the output onto the field of the document.

By I am trying to run that agent on the server by calling agent.RunOnServer and seems the SendConsoleCommand does not work using this method.

If run the agent using normal run ie by “agent.Run” it works.

Here the codes that call the agent to run:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim docTemp As NotesDocument

Dim agToRun As NotesAgent

Dim szUNID As String

Set db = session.CurrentDatabase

Set docTemp = New NotesDocument (db)

docTemp.TriggerUserName = session.UserName

Call docTemp.Save (True, False)

szUNID = docTemp.UniversalID

Set agToRun = db.GetAgent (“Show Users”)

If agToRun.RunOnServer (docTemp.NoteID) = 0 Then

    Set docTemp = Nothing   'force notes to find the doc by unid!

Set docTemp = dbAdmin.GetDocumentByUNID (szUNID)

Messagebox docTemp.ReturnValue (0)

End If

Call docTemp.Remove (True)


And this is the called agent (“Show Users”):

Dim session As New NotesSession

Dim db As NotesDatabase

Dim szReturn As String

Dim agCurrent As NotesAgent

Dim docParam As NotesDocument

Set agCurrent = session.CurrentAgent

Set db = session.CurrentDatabase

Set docParam = db.GetDocumentByID(agCurrent.ParameterDocID)

szReturn = session.SendConsoleCommand (db.Server, “Show Users”)

docParam.ReturnValue = szReturn

Call docParam.Save (True, False)


Actually I want to process the return value.

The reason I want to run on server because the user who run the codes above probably does not have administrator right to run remote server command.

The agent will be signed by person who has full administrator rights.

I call agToRun.Run it works and I get the expected return value but not when RunOnServer. Ther ReturnValue will contain null or empty.

I have tried many options on the agent including tick the option “Run in background client thread” but not to avail.

Am I missing something here or it is a bug in notes ?

Thanks in advance

D Surjadi

Subject: SendConsoleCommand used by agent RunOnServer

I don’t have any example code to post but if you look in the domino web administration db there is code that can be used for pulling back the results of server commands. HTH!

Subject: RE: SendConsoleCommand used by agent RunOnServer

I have looked at the database but I do not know which design elements to look at. Could you tell me what or design elements (forms, agents etc) to look at ?

Thanks

Djaja