I use this administration agent in my databases to quickly change the “run on” server for all f the scheduled agents when I deploy a template to a new server.
The other approach I use is to have the agent “run on all servers” but to then have each agent check for a configuration document in the database which then lists which servers it is allowed to run on. If the current server is not in the configuration document then the agent exits.
Sub Initialize
Dim session As New NotesSession
Dim ws As New notesuiworkspace
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim askme As Variant
askme = ws.Prompt (PROMPT_OKCANCELEDIT, _
“Suggested Server”, _
” You must use the format CN=….” ,db.server)
If Not Isempty (askme) Then
Forall a In db.Agents
If Not a.servername = “” And Not a.servername = “*” Then
If a.servername = askme Then
Print a.name + ” already set to run on chosen server”
Else
Print “changing ” + a.name + ” from ” + a.servername + ” to ” + askme
a.servername = askme
Call a.save
End If
End If
End Forall
End If
End Sub