-2

our project is running in VB6 technology, we want a batch file which will run all our VB6 projects at a short and need to give us the output files.

Suppose using Visual Studio we can run the vb project once we build that project we will get the Output as .exe file. In similar way when we run the batch file it need to pick the ABC.vbp file and build it then the output should come in appropriate location as ABC.exe.

Please help in doing this to our project. This will help us a lot to me and my teammates.

Thanks in Advance.

  • Possible duplicate of [How to write a batch file to get the builds for all VB6 projects](https://stackoverflow.com/questions/51879449/how-to-write-a-batch-file-to-get-the-builds-for-all-vb6-projects) – C-Pound Guru Aug 17 '18 at 13:06

1 Answers1

0

Depending upon the complexity of your project, creating a working "build" batch file can take a bit of tinkering to get to work, but it's definitely possible. If it's just a single executable file you're after, then you can just run the VB6 compiler in command-line mode, as follows:

"C:\Program Files (x86)\Microsoft Visual Studio\VB98\vb6.exe" /m "C:\Project\Source\MyProg.vbp" /outdir "C:\Project\Runtime"

Put that line in a batch file, and you're done. Note all the quote marks; they're necessary for the Windows command processor to work. The /m switch means "make" the project using the settings in the VB6 project file. Note also that by using the /outdir switch, the target directory doesn't need to be the same as the directory(s) containing the source.

If you want to make a nice distributable package, with a Setup program that will automatically copy all the other files needed (VB6 runtime, any DLLs or OCXs, and any other files your application needs), then you'll need to use the Package and Deployment Wizard. Roughly, here are the steps:

First, use the Package and Deployment Wizard in interactive mode (under Tools in the VB6 start menu) to create a Distributable Package, which will wind up creating a setup.exe program, a SETUP.LST file, and a .cab file containing your executable, the VB6 runtime, and any other modules or files you've defined as necessary with the Wizard. It also creates a .PDM file, which is essentially the packaging script to generate the setup files mentioned above. (It also tweaks some other files and registry entries, so don't think that you can just go editing the PDM file willy-nilly - it won't work as you hope.)

Let's assume that you're building all of this in a directory called C:\Project, with subdirectories for Source, Runtime, and Source\MyProg_Setup. These will be the directories you'll substitute into the following examples.

The first thing your batch file must do is compile the program, which means running VB6 in command-line mode, as described above. Next, your batch file can run the Wizard in command-line mode, but it's very picky about how it's run. First, the destination folder (that was created the first time you ran the Wizard) must not exist, so the first line in your batch file must remove it:

rd /s /q C:\Project\Source\MyProg_Setup

This will remove the Setup directory, and all subdirectories (/s), and won't ask for any confirmation (/q), which is what you want in a batch file. Now you can run the command-line version of the Wizard, using the MyProg.PDM file that was generated when you ran it in interactive mode:

"C:\Program Files (x86)\Microsoft Visual Studio\VB98\Wizards\PDWizard\PDCMDLN.exe" "C:\Project\Source\MyProg.vbp" /p "MyProg_Setup" /l "C:\Project\Source\MyProg_Setup.log"

This will re-create the MyProg_Setup subdirectory, along with the setup files to distribute to your end users. The command-line switches used here are: /p is the name of the packaging script (less the .PDM extension), and /l (lower-case "L") directs the output to a log file, so that you can see what went wrong.

You need to provide the end users with the files:

  • setup.exe
  • SETUP.LST
  • MyProg.cab

all in one directory, perhaps on a CD-ROM or a flash drive.

There is original Microsoft documentation on using the Wizard, but it can take a while to track down. In addition, the PDW is not well thought of, especially in current times (this century...), so you might look into alternative deployment tools, such as the excellent (and free!) Inno Setup installer.

Mark Moulding
  • 549
  • 2
  • 5