Visual Basic to run other other software?

KEANEJ used Ask the Experts™

I am using VB6 and IBM Client Access Express (for AS400).
I want to be able to write some vb code that will automatically run a Client Access Data transfer file
(ie .dtf files)

Is there any code examples on the web i could customize ?


John Keane

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

haqve you tried using shellexecute api?

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Call ShellExecute(hwnd, "Open", ("C:\somefile.dtf"), "", App.Path, 1)
End Sub



That code worked to a certain extent, when i put that code behind a button it brought up the client access transfer window which i would normally get by double clicking a .dtf file, in that window there is a button labeled
 "Transfer Data from AS/400" by clicking this a file is transferred from AS400 to a PC.

Is there additional code i can add to actualy run the transfer automatically ?

Many Thanks

John Keane

Does the transfer button have an underlined Letter on it?
If so maybe you can use Sendkeys to press the button.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Just shell RTOPCB.exe and RFROMPCB.exe.

These are the batch versions of file transfer. If you run them without parameters from the command window you'll get additional info on how to add parameters to specify which transfer file to execute and various options like show warnings etc.

There may be arguments for automatically updating/transfering. If not, just execute the dtb file.

You do not need extra declaratioons as vinny said, instead just use the shell command.

Shell "FileName",0 'Zero can be replaced to fit your needs

Or if the file path/name has spaces in it:

Shell chr(34) & "File Path and File Name" & chr(34),0

Some files will not run directly, such as websites, and running shortcuts, such as aim:// http:// ftp:// In this case you would do:

Shell "start " & chr(34) & "",0


Shell "explorer " & chr(34) & "",0

In your case try to use start and point to the dtb file.

dtf file, sorry.

ShellExecute is a better way to launch a URL.It will launch the file with the program associated with the file.
Guilt and vinnyd79,

if you don't know what Client Access and AS/400 are please save your comments: you're just confusing people...

Why would you need to know what they are to execute a file?

cparlanti, sorry I confused you.
Client Access has 3 file transfer programs, CWBTF.exe,  RTOPCB.exe and RFROMPCB.exe.

The first one is an interactive program and can be run with options /f or /t to either download or upload files with user's intervention.

This program can save .dtf and .dtt transfer files (using eventually a .dfd to describe the PC file format). The .dtf and .dtt files are associated to CWBTF.exe at the shell level.

Although it is theoretically possible to either shell CWBTF.exe or a .dtf/.dtt file and then use the window handle to get an handle to the "Transfer data from AS/400" or "Transfer data to AS/400" button and press it, try to think about this:

In his magnanimity IBM has designed two additional transfer programs. They are called RTOPCB.exe and RFROMPCB.exe that can use the same file transfer description files (.dtf and .dtt). The main difference in these programs is that they are designed to run without user's intervention (batch mode).

Let me think... what should KEANEJ do?
Author of the Year 2009

It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept cparlanti's comment(s) as an answer.

KEANEJ, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer
per recommendation

Community Support Moderator @Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial