How can I run an exe script file multiple times in vb6?

Hi, I use some scripts to automate the editing of my database (the scripts are .exe files). Whenever I add an item to my database, I put the item into the system, (its a database file so I use excel to edit the database) but when I enter the info in, to save time I just the item name.  Then every week or so I edit all the recent items I added (theres like 20 fields which have to be modified per entry). So I made a script which automates this process. My question is I was wondering is there an easy way to specify how many times an exe file with a time delay between each time it runs.

Since I add anywhere from 0-200 items to the database every week, each week the number of times the script is ran changes.  

I wish there was an option to say run this script 148 times and it will loop itself 148 times. Currently I edit the script and use Copy and paste then save the script file and compile it to an exe file and run it. The only times I have problems are when I lose count  if I accidentally paste an extra script in it will mess up a record (if I need it to revise 50 items and its pasted 51 times, the 51st item will be messed up). And if I miss a paste and paste 49 times lets say, then I need to edit the script to only run once, save and run it.

I know how to use visual basic 6 a little, so it would be cool if I can load a script in vb6 and type in a value- and have it run that script that many times. For example I can press a button and browse to the directory on my computer c:/scripts and select the script I need, then in another box type in 50 for example, and press ok and have that script run 50 times.

A problem is that if it ran like that, a timer would need to be involved because if I said to run a script 50 times, all the scripts may load at once. It would be important that the second script launches after the first script has ran and the process has been completed.

I made a sample of what the program looks like, see it below

Does anyone have any advice on the coding? It looks like it should be easy, but I havent used VB in an advanced way like this since high school a few years ago. Any help would be appreciated.

Image4.jpg
mds332200Asked:
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.

dentabCommented:
It might be overkill a little, but I have just written a class (will nicked bits off the web and stuck it together) that will do the job.

Paste the code snippet  into a new class and call it CPROC

Then this code would work

Sub Form_Load
  LaunchApp "c:\windows\notepad.exe", 5
End Sub

Sub LaunchApp (ByVal path as String, optional byval numtimes as Integer)
  Dim MyObj as CPROC, n as Integer
  Set MyObj=New CPROC
  For n = 1 To numtimes
    MyObj.Application = path
    MyObj.Initialise IDLE_PRIORITY_CLASS, False, SW_MAXIMIZE, True  
  Next n
  Set MyObj=Nothing
End Sub

as an example
Public Enum APPLICATION_WINDOWSTATE
  SW_SHOWDEFAULT = 10    ' Sets the show state based on the SW_ value specified in the STARTUPINFO
  SW_SHOWMAXIMIZED = 3   ' Activates the window and displays it as a maximized window.
  SW_SHOWMINIMIZED = 2   ' Activates the window and displays it as a minimized window.
  
' Windows 2000/XP: Minimizes a window, even if the thread that owns
' the window is not responding. This flag should only be used when
' minimizing windows from a different thread.
  SW_FORCEMINIMIZE = 11
 
 
' Hides the window and activates another window.
  SW_HIDE = 0
 
' Maximizes the specified window.
  SW_MAXIMIZE = 3
 
' Minimizes the specified window and activates the next top-level window in the Z order.
  SW_MINIMIZE = 6
 
' Activates and displays the window. If the window is minimized or maximized,
' the system restores it to its original size and position.
' An application should specify this flag when restoring a minimized window.
  SW_RESTORE = 9
 
' Activates the window and displays it in its current size and position.
  SW_SHOW = 5
 
 
' Displays the window as a minimized window. This value is
' similar to SW_SHOWMINIMIZED, except the window is not activated.
  SW_SHOWMINNOACTIVE = 7
 
' Displays the window in its current size and position. This value
' is similar to SW_SHOW, except the window is not activated.
  SW_SHOWNA = 8
 
' Displays a window in its most recent size and position.
' This value is similar to SW_SHOWNORMAL, except the window is not actived.
  SW_SHOWNOACTIVATE = 4
 
' Activates and displays a window. If the window is minimized or maximized,
' the system restores it to its original size and position. An application should
' specify this flag when displaying the window for the first time.
  SW_SHOWNORMAL = 1  
End Enum

Open in new window

0

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
ee_rleeCommented:
hi
check this out.

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=27238&lngWId=1

just change the filename on Form_Load to your filename and add a loop on Command1_Click on how many times you want the exe to execute. you will not have problems with the timing here because it will wait for the exe to finish processing (end) before calling the next exe.
0
mds332200Author Commented:
Thanks for the help!
0
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.