Outside Of App or Inside

I have an app and it shells and IBM communication app which sends me to a user sign on. I need to sign on because the files I need to access are within the mainframe side of things.

Once at the sign on I am outside my app so if I sign on I get to the dos prompt which is where I want to be, but my app is in limbo.
Once I reach the dos prompt I need to move files-change dir-etc. I can do this with a bat file. But as I'v stated, my app is (I don't know where it is), I've left it behind at the sign on.

How do I
1. use my app to sign on and proceed with shelling the bat file.
2. have my app kick in after I sign on

What I am missing is the ability to signon as user and then proceed.
Just the middle..I can do the steps before and after...I need the communication.
Hope this makes sense.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Wayne,

If you're using a batch file anyway, can you not have it create a file at the end of the batch instructions ... which your VB program is then looking for the existence of, and when it finds it knows to proceed?
SendKeys will communicate between your app and anything that you've used SHELL to start. Here is a sample:

' Start child process and get handle
RetVal = Shell(Quote & Adobe_Path & Quote, vbMaximizedFocus)

' Send a series of commands to child
sendit ("%WA")                      'Close all windows
sendit ("%FO" & datadrive & "\" & filename & "{enter}")
sendit ("%VG")                      ' Issue page select command
sendit (onpage & "{enter}")         ' Specify page

Private Sub sendit(txt As String)
' Send string to child task
On Error Resume Next    'Ignore any errors that occur
AppActivate RetVal      'Make sure child task is active
DoEvents                'Give it a shot to run
SendKeys txt, True      'Tell it what to do and wait
DoEvents                'Cede some more time
End Sub

This should help you out.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JuiletteAuthor Commented:
Ok..Vettranger...not sure what you are trying to tell me...I don't start with a bat I use a bat once inside the working enviroment.

You are 500 miles ahead of me...I'm new to most of this and learning but I'm still taking baby steps and you're in full gallop...

Here is my testing app of what I've got and hopefully you can fill in what is missing.
I use shelldef because I don't know the ext of the ibm pgm I shell.
'shell the imb sign on
    ShellDef ("C:\Program Files\Microsoft Office\Office\Shortcut Bar\Office\s390")


I have to login here...enviroment, username and password.
either manual or through code...

 What do I have to do to stop and have my app sign on.
 example code would be nice. Sign on is 3 things.
 1. c or d or e
 2. username
 3. password

 Then after I sign on x can be processed


 X      This happens after I sign on      x
Dim iIntNum%   'file number variable

sPikName = txtPikName.Text     'initilaze the variable

iIntNum = FreeFile           'initilaze the varaible

'open a file as a .bat file and write to it
    Open "C:\PickBat.bat" For Output As #iIntNum
'write to file
    Print #iIntNum, "@echo off"
    Print #iIntNum, "C:\"
    Print #iIntNum, "copy c:\books\" & sPikName & "*.txt c:\AHelper"

'close the file
    Close #iIntNum

'shell the bat file
    ShellDef ("C:\PickBat.bat")

'let it finish
  'is this a Doevents

  'similar to login

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

I think Mark has the answer if you read it one line at a time it not to hard to understand. What his code does is control the shell app by sending keystrokes just as if you type them from the key board. I find if I don't understand someone code I will paste it into a sample project and press F8 and step thru the code line by line till I understand it. Well that my 2 cents worth good luck.
JuiletteAuthor Commented:
I don't doubt Mark's expertise for a moment .... it's the distance between our understanding that obscures the answer.
Lets go over it a bit at a time:

' Start child process and get handle
RetVal = Shell(Quote & Adobe_Path & Quote, vbMaximizedFocus)

This is starting the external app. In the program that this is lifted from Quote is " and Adobe_Path is the fully qualified name of the application. Using your code you'ld write:

RetVal = Shell("C:\Program Files\Microsoft Office\Office\Shortcut Bar\Office\s390")

RetVal is a numeric identifier of the task ID associated with the child task. You keep this on hand to know "where" to send commands.

I have a subroutine called SENDIT that is used to send messages to the child task. You pass it the information you want to send as if you were typing from the command line. Certain function keys and control keys have special symbols. See the SENDKEYS command in the help for more details. Again referring to your code you might code:

Username = "MyLoginName"
Password = "MyPassword"
SENDIT("C") ' or "D" or "E"
SENDIT(Username & "{enter}" )
SENDIT(Password & "{enter}" )

The "{enter}" tells the routine to send the <Enter> key (this is from the SENDKEYS help). Each invocation of SENDIT will wait for the command to compelete before continuing.

The SENDIT routine is used as is.

Any other questions, just ask.

JuiletteAuthor Commented:
Sorry, all I could give you was an A

OK...I will figure this out but if you will...I use shelldef instead of shell because I can't get the extension of the S390 ibm app. If I shell it with exe, dos, or bat I get can't find file.

If I ShellDef it opens. How can I get the handle of this app so I can apply what you've give me...retval doesn't work with shelldef.



What threw me for a loop was this>>>' Send a series of commands to child
sendit ("%WA")                      'Close all windows
sendit ("%FO" & datadrive & "\" & filename & "{enter}")
sendit ("%VG")                      ' Issue page select command
sendit (onpage & "{enter}")         ' Specify page

JuiletteAuthor Commented:
Thanks Mark...sorry about the low points for the question but that's all I had when posted.

Do a search on your HD and find the extension fo the S390 app yourself. My guess is that it's a .LNK (shortcut). If you look in the named shortcut you should see that actual name of the app. Calling it directly should speed things up and allow use of SHELL instead of SHELLDEF.

The commands listed were lifted out of an actual app. The % is interpritted as <ALT> with the next character. See the details on SendKeys in the help to make sense of it all.

Don't worry about the points. Glad to help.

JuiletteAuthor Commented:
I did a find on the HD and it comes back listed as S390....no extension....when I get to work I'll try the .lnk and see it I can get it to work...if not I'll do it the old fashioned way and try and find the documentation that came with the IBM Communition App.

Thanks again
JuiletteAuthor Commented:
If you are still connected.
The file is a WS extension.
Under properties it says..DosName = s390.WS
I even tried to shell the lnk file pertaining to it but it won't shell
only shell def...

the shell command is good ..I've used it many times.
I can shelldef it only.

Is there another way to get the hwnd so I can send keys to it.

This looks to be like an office shortcut. What happens if you SHELL to S390.WS?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.