Connecting up with PCAnywhere client with command line

R Keshavan's picture

I see that you can connect to a Host via the command line with something like this

 

Awrem32.exe C:\launcher\TestConnection2.CHF /Clocalhost

 

But I don't see any way of specifying a username/password.  We need to be able to have the client directly connect and specify the username/password.  Would this be possible?

Thanks!

 

Pearl's picture

Hi Keshavan,

 

It is not possible to specify caller via commanline. However, If you want to user to directly connect to the host when he runs awrem32.exe, you may want to save the username password in th remote item (.chf file) itself. For this:

1. Open Remote Item properties> Settings tab> Login Information

2. Select the checkbox and then enter the caller details of the host.

3. Save this remote item and run it via commanline. 

This will directly go and connect the host.

 

Thanks,

Pal 

 

R Keshavan's picture

Hi Pearl,

 

Thanks for your answer.  I did know about that solution, but what we want to do is be able to store the username/password in a database and be able to retrieve that and make automatically launch the PCAnywhere client to connect to the server, without the user being prompted for the username/password. 

 

Is there any way to create the .chf file on the fly?

I've also been looking to see if the OLE API to do this, but it doesn't look possible.

 

Thanks.

 

Rango

Asj's picture

Hi Rango,

            Yes, you can achieve autologin using OLE.For that you can use CRemoteData's  AutoLoginName(String) & AutoLoginPassword(String) properties. Please refer pcAole.pdf to read more about CRemoteData object.

 

Thanks,

Aj

KevinPHolbrook's picture

Thanks for the info ASJ.

 

One question, though. It seems like we can use this to open a remote connection and subsequently transfer files and send commands. 

 

Can we spawn the client interface from OLE?

 

We want the PCAnywhere session to retrieve credentials from a trusted source, dynamically generate the CHF file, and the spawn the PCAnywhere Client without any credential challenge.  

 

Is this possible with OLE? If so, what is the command to spawn the client. 

 

Many thanks!

KevinPHolbrook's picture

The following code works for us now:

 

BOOL LaunchPCAHost(LPCTSTR lpszAddress)
{
    BOOL bReturn = FALSE;
    CRemoteDataManager    remoteDM;
    CRemoteData            remoteData;
    CRemoteDataManager    remoteDM2;

    // First, create the CRemoteDataManager
    COleException Error;
    BOOL b = remoteDM.CreateDispatch("WINAWSVR.RemoteDataManager", &Error);
   
    // specify the name of the CHF file. There are 2 things to note here:
    // 1. The file must be unique, as the subsequent calls will attempt to create this file, ans will fail if the file can't be created
    // 2. The file is stored in the Symantec app data folder, which by default is:
    //    C:\Documents and Settings\All Users\Application Data\Symantec\pcAnywhere\
    CString CHFFile = "Connection444.CHF";

    LPDISPATCH pDispatch = remoteDM.CreateObject(CHFFile);
    if(pDispatch == NULL)
        pDispatch = remoteDM.RetrieveObject(CHFFile, 0, NULL);
    ASSERT(pDispatch);

    // Next, create CRemoteData and attach it
    remoteData.AttachDispatch(pDispatch);

    // Now, set the required properties
    remoteData.SetConnectionType("TCP/IP");
    // set the remote host IP
    remoteData.SetComputerName("192.168.1.1");
    // set the remote login credentials
    remoteData.SetAutoLoginName("pcpc"); // put actual username here.
    remoteData.SetAutoLoginPassword("pcpc"); // put password here.

    // Save the object data
    remoteData.WriteObject(0);

    // release the dispatch handlers
    remoteData.ReleaseDispatch();
    remoteDM.ReleaseDispatch();

    // launch the the remote connection, which will spawn the PC ANywhere client
    b = remoteDM2.CreateDispatch("WINAWSVR.REMOTEDATAMANAGER");
    b = remoteDM2.Launch(curFile);
   
    return TRUE;
}

 

Hope this helps!

 

Many thanks to Harry Feng for this example. 

Pearl's picture

Hi KevinPHolbrook,

 

Thanks for the update.

 

Pal