The simplest approach to check whether the current user already has a running connection Integrity is the "si servers" command.
It lists all running connections to all servers and for all users currently established on this client, like this
<user>@<server>:<port>
If there is no connection it returns an empty string.
so for a batch file:
1. run "si servers" (it also starts the client it necessary)
2. search the resulting output for the correct triple: user, server and port
If it cannot be found, use "si connect" to connect your user to the server. (the "--gui" would enforce an interactive login).
If you you find it, you know the is a runnign connection you can use.
3. go ahead with your batch code
HTH Matthias