Have you tried the PCSAPI functions; I have used them, if you know the path of the .WS file you could start the session not using the shell command
pcsStartSession
3270 5250 VT
Yes Yes Yes
The pcsStartSession function starts a host session by using a specified workstation profile. A short session ID can also be specified.
Function Type
ULONG WINAPI pcsStartSession(PSZ lpProfile, char cShortSessionID, USHORT fuCmdShow)
Parameter Type and Description
PSZ lpProfile
Path and complete filename of the profile to load. Path is optional but complete filename must be specified (.ws extension is not assumed).
char cShortSessionID
Presentation space short session ID. Space or NULL indicates the next available session ID.
USHORT fuCmdShow
Specifies how the window is to be displayed. One of the following values from PCSAPI.H:
PCS_HIDE
PCS_SHOW
PCS_MINIMIZE
PCS_MAXIMIZE
Return Code
Return Code Value Meaning
PCS_SUCCESSFUL 0 The function ended successfully.
PCS_INVALID_ID 1 An incorrect session ID was specified.
PCS_USED_ID 2 The specified short session ID is already used.
PCS_INVALID_PROFILE 3 An error was made in specifying the workstation profile, or the window parameter was not valid.
PCS_SYSTEM_ERROR 9 A system error occurred.
--------------------------------------------------------------------------------
pcsStopSession
3270 5250 VT
Yes Yes Yes
The pcsStopSession function stops a host session specified by the short session ID.
Function Type
BOOL WINAPI pcsStopSession(char cShortSessionID, USHORT fuSaveProfile)
Parameter Type and Description
char cShortSessionID
Presentation space short session ID.
USHORT fuSaveProfile
This parameter can be one of the following values:
fuSaveProfile Value Meaning
PCS_SAVE_AS_PROFILE 0 Save the profile as specified in the current profile.
PCS_SAVE_ON_EXIT 1 Save the profile on exit.
PCS_NOSAVE_ON_EXIT 2 Do not save the profile on exit.
Return Code
Return Code Meaning
TRUE The function ended successfully.
FALSE It means one of the following things:
The session has not started.
An incorrect session ID was specified.
Hope it will work
