Our project is running in VB6 technology, we want a batch file which will run all of our VB6 projects at a short and needs to give us the output files. Using Visual Studio, we can run the vb project once we build that project we will get the output as .exe file. In a 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 an appropriate location as ABC.exe.

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

Some name

It is not good practice to build your project every time you run it. The risk is that somebody may be working on the project when the batch file gets run. The reports you run may not be the ones you tested. They may even not compile at all.

You should build and test the project, then freeze all the sources and make it into a release. At that point, everything should be backed up. Then install it on the run-time machines. For security, your development and run-time systems should not be the same machines. Consider for example what happens when you take updates to Windows and VB -- do you really want to run the code without testing it under the updated environment?

If you get a proper release cycle in place, then just running the reports is easy. A batch file for that just invokes the reports -- it does not need to do any project builds.

So if your .vbp file is in c:\Dev\Project1, that's latestSource. latestBuild is wherever you want to put the resulting exe. For multiple projects, you can make multiple latestSource and latestBuild variables, or you can just put the directory straight into where the variables are. Like so:

REM Make the builds directory if it doesn't exist
if not exist "C:\Project1\output" mkdir "C:\Project1\output"
if not exist "C:\Project2\output" mkdir "C:\Project2\output"
if not exist "C:\Project3\output" mkdir "C:\Project3\output"

You can test these just by running the text in the DOS prompt. Then when you have what works, save it in a .bat file and there you go. Quotes are there because in my case there are spaces in the path. They are not needed if there are no spaces, but if there is the possibility of spaces at any point then you need them, so it's better to leave them.

Answered

Sorry! Something went wrong on our end. Please try again later.

Christos_Psarras

August 17, 2018 03:28 PM

Go to the folder/directory VB6.EXE is located, open a Command prompt, and run it with the /? parameter, i.e. VB6.EXE /?

This will give you all the available options the compiler can accept. You can then use pixelmeow's batchfile and adjust it to fit your specific needs. And like he/she said, leave the quotes, it's a good practise to always use them even if there are no spaces in the path, so this way any future changes to the path(s) that may introduce spaces won't break the batchfile.

If the desire was to create the latest builds of projects then the .bat script suggested above seems appropriate. If wanting to build and execute the projects then that needs more actions such as creating a test .bat file to execute the .exe results (assuming they all successfully compiled).

If just wanting to automate running the current production .exe then the project files have nothing to do with that. A .bat script to execute the .exe will point to the installed run-time location/path and could be set to run automatically. (Not providing an example but would be similar to the previous code except running the .exe)

(99.9% work experience as mainframe application programmer but have used PC since before IBM got into [and then out of] the PC business.)

Answered

Sorry! Something went wrong on our end. Please try again later.

Paul Pedant

August 17, 2018 06:44 PM

I am no Windows enthusiast myself, but I can't believe there are not at least two better ways of doing the builds.

(1) The script provided has a bunch of cut and paste to work for 3 projects. But what if you have 30 projects? How about a script that builds one project, but takes parameters for the project name, and gets invoked from an outer script 30 times?

(2) I can't believe an established tool like Visual Studio for VB does not provide a way to associate a group of projects, such that you can rebuild the whole group with one click.

(3) Take a look at google "man linux make". There's a tool that can be configured to build an entire OS release, reliably and unattended, and to build just those components that are out of date or rely on other such components.

Answered

pixelmeow

August 17, 2018 11:42 PM

Newer versions of Visual Studio do allow you to group projects together into solutions and build the whole thing. This version of Visual Studio, which is from the late 90s, does not. One project at a time. The only reason I even have a batch file is because my company is moving our VB6 projects to Jenkins, which builds everything for you and deposits the output in buckets on an Amazon web server for the deployment team to pick up directly instead of getting from the developers. I can definitely see the need for something like this, I have fifteen separate projects that I could build all at one time like this if I needed to. Yes, it's a lot of copy/paste, but that's just how this twenty year old IDE works.

A list of projects used to repeat a generic make script with the project names as a parameter would be better than updating the script in multiple places if a project is added or removed. A script better than a .bat file would also make sense. If projects are not known in advance other than directory, then maybe a directory list could be massaged into the parameter list.

I do not recall the capabilities or which version of VS might be used. Should have some sort of capability to do a make on a group of projects that maybe could be executed as well. (group version of the vb6 /make ...)

Linux cannot be the only place that builds are routinely done.

The mention of "VB6.EXE /?" was a hint on how to find more help or at least extra parameters.

Answered

Sorry! Something went wrong on our end. Please try again later.

Christos_Psarras

August 18, 2018 09:33 AM

Paul, you are correct, the batchfile provided above can be separated into two batchfiles, one that accepts parameters and does the actual compiling (and whatever else may be needed on a per project basis), and another one which will call the "compiler" batchfile; something like this for example:

Project_Rebuilder.bat:

@echo off

REM Set the path variable to include the compiler's folder

set path=%path%;"c:\Program Files (x86)\Microsoft Visual Studio\VB98"

REM Build the project(s)

call VB6maker.bat "C:\Dev\Project1\project1.vbp" "C:\Project1\output"

...

...

...

VB6maker.bat:

@echo off

REM Make the builds directory if it doesn't exist

if not exist %2 md %2

REM Build the project

vb6 /make %1 /outdir %2

Answered

Sorry! Something went wrong on our end. Please try again later.

Christos_Psarras

August 18, 2018 09:39 AM

Pixelmeow, one small correction, the VB6 IDE
does have the capability of compiling more than one VBP project at a time, search the VB help for Group Project; you can create a VBG file which contains all the VBP projects you want to associate for a project, and when you make the VBG the ide will make all the VBPs it contains.

Answered

Sorry! Something went wrong on our end. Please try again later.

Paul Pedant

August 18, 2018 10:14 AM

You might wonder what security holes there are in a product that had its final release 20 years ago, and went out of support completely 10 years back.