Jump to content

[VB6] Multiple Program Launching


Recommended Posts

What i want to do is:

1. Have all the .exe's in a directotry launched in numerical, one at a time.

2. and also use switches with them

3. if i add more .exe's to this directory they will also be launched

Ive searched everywhere for this and ive not been able to find it.

So if any one knows how to do this could you help me out here.

Thanks in advance.

Link to comment
Share on other sites


What you're trying to do is quite easy, however, I am not sure what you mean by launch exes in numerical. Could you maybe give an example of some of the exe files you'd have (and thus need to launch) and I can try to help you. :)

Link to comment
Share on other sites

what im trying to do is make a program that will install the windows updates for windows 98, ME, 2000, and XP. The numerical order is not neccessary but if possible would be prefered.

EDIT: Just incase your curios ive already got the prog to detrmine which os is running which i got from the ms site.

Link to comment
Share on other sites

First, define this API in a global area: (such as in the top of a form or in a module) We'll use it to execute external files (Don't use Shell(), it is horrible)

Public 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

You must reference the "Scripting type library" for the following to work. I haven't installed VB now (Since I've migrated to VB.NET) but I think you'll find it in Proejct -> References or something. The list should be alphabetically sorted, so just put a checkmark on "Scripting type library". (File name: "scrrun.dll")

Then, do something like this to find and exectute files:

Dim FSO As FileSystemObject
Dim File As File

For Each File In FSO.GetFolder("<path-to-folder-containing-exe-files").Files
   ShellExecute Me.hWnd, "open", File.Path, vbNullString, "", 1
Next

This piece of code does no filtering for you though. I'm sure you can figure it out from here, and in case not, do not hesitate to ask more. I'll do my best to help. Oh, btw, the place that I put vbNullString you can replace with for instance "/S" or something, it's the parameters you pass to the file.

Link to comment
Share on other sites

cant seem to get the code to work

i put the API in a module of its own

and i copied the other code in CmdInstall (currently only command button on the form) and it keeps giving me this:

Run-TimeError 91

Object variable or With block variable not set

i have had no luck with messing around with it for the past 6 hours

any help would be appreciated

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...