|
-
Oct 27th, 2000, 08:41 AM
#1
Thread Starter
Lively Member
I created a VB 6 app that multiple user run on their workstation. The installation
package is on the production server in a place called \\WhatEverServer\Software\MySoftware.
In that spot, there is the executable (which I recreate "recompile" from time to time) and the
installation package.
I need to be able to update the PC's because of minor changes et whatever. I'll probably
create an executable that will check if the application is currently running and if not, copy the
new executable file from the server to the PC.
- How to find out if the application is currently running?
- What kind of code do I need to copy the updated
executable from the \\WhatEverServer spot to the PC?
TIA for any advice and/or sample code
Sincerely yours,
Patrice B. 
Information System Analyst
SAS 9.1.3, VB6 SP6, VB.Net 2003, SQL7.0/2000
-
Oct 27th, 2000, 11:02 AM
#2
Fanatic Member
Saw no replies and took pity...
I am sure that I have something to do this at home - I will revert to you on Monday.
Paul
Not nearly so tired now...
Haven't been around much so be gentle...
-
Oct 27th, 2000, 11:11 AM
#3
Thread Starter
Lively Member
Thanks ... for the moment... At least one reply
Sincerely yours,
Patrice B. 
Information System Analyst
SAS 9.1.3, VB6 SP6, VB.Net 2003, SQL7.0/2000
-
Oct 31st, 2000, 12:47 PM
#4
Any Answers yet?
I don't know the answer, but this is the question I had and I'm having trouble posting a new thread so I am replying in order to reintroduce the question.
On startup of my app I want to see if there is another instance already running. Any help is appreciated.
-
Oct 31st, 2000, 12:53 PM
#5
Thread Starter
Lively Member
I've been searching in a bunch of VB sites and found only one reference (16 bits version for VB3 or 4). There must be something out there somewhere...
Awaiting the comeback from PaulW. Hope he'll be succesfull in retreiving what we need.
Sincerely yours,
Patrice B. 
Information System Analyst
SAS 9.1.3, VB6 SP6, VB.Net 2003, SQL7.0/2000
-
Oct 31st, 2000, 12:55 PM
#6
Hyperactive Member
Maybe (BIG maybe) I can help
This probably has nothing to do with what you said but ,hey, at least I'm thinking :-). If the workstations the application is supposedly running is NT or 2000, then do Ctrl-Alt-Del to open task manager. That will tell you the status of all/any applications running at that time on that workstation.
Hope this helps.
-
Oct 31st, 2000, 01:02 PM
#7
Thread Starter
Lively Member
Ok... I see your point (I think ). Then how do we integrate that into a VB app? Worse, how to make sure that will work on Win9x flavors?
I'm lost...
Back to square two (we at least have something going)
Sincerely yours,
Patrice B. 
Information System Analyst
SAS 9.1.3, VB6 SP6, VB.Net 2003, SQL7.0/2000
-
Oct 31st, 2000, 01:04 PM
#8
Thread Starter
Lively Member
I forgot... If you implied that the user could determine if the apps is running... forget it... They don't know.. Even if I explain them what to look for.
Sincerely yours,
Patrice B. 
Information System Analyst
SAS 9.1.3, VB6 SP6, VB.Net 2003, SQL7.0/2000
-
Oct 31st, 2000, 01:12 PM
#9
Do your users run only one instance of your application? I mean do you have your EXE somewhere on the LAN where everyone has access to? Or each user has it's own copy?
If they use the LAN version, then you can do something I've done some time ago:
Instead of having an EXE on the LAN, have a batch file which the user will run. This batch file will copy your EXE from the LAN to their local drive and execute it. This way, you can always upgrade your EXE without being worrying that someone is running it. As far as a user concerned, as soon as he/she rerun the batch file, the new version will be copied.
Just a thought,
-
Oct 31st, 2000, 01:25 PM
#10
Hyperactive Member
Re: Any Answers yet?
Originally posted by help<
I don't know the answer, but this is the question I had and I'm having trouble posting a new thread so I am replying in order to reintroduce the question.
On startup of my app I want to see if there is another instance already running. Any help is appreciated.
Code:
If App.PrevInstance = True then
Unload Me
End If
Now to tthe other problem. What you could do is just try and update the file. If the program is running you will get an error message that says something to the effect of "sharing violation".
-
Oct 31st, 2000, 02:31 PM
#11
Junior Member
1. If you try to copy the file to the workstation, you will get an error if the file is in use. Trap this error and you know which workstations are currently using the application.
2. The App.PrevInstance will only indicate if another instance of this application is running. You can't use it to detect other applications.
3. To get a list of all applications/proceses currently running, start a new project, add a command button and a list box to Form1.
I think that I found this code here. You can modify it to suit your needs (i.e. find a specific exe file running)
Code:
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Private Sub Command1_Click()
LoadTaskList
End Sub
Sub LoadTaskList()
Dim CurrWnd As Long
Dim Length As Long
Dim TaskName As String
Dim Parent As Long
List1.Clear
CurrWnd = GetWindow(Form1.hwnd, GW_HWNDFIRST)
While CurrWnd <> 0
Parent = GetParent(CurrWnd)
Length = GetWindowTextLength(CurrWnd)
TaskName = Space$(Length + 1)
Length = GetWindowText(CurrWnd, TaskName, Length + 1)
TaskName = Left$(TaskName, Len(TaskName) - 1)
If Length > 0 Then
If TaskName <> Me.Caption Then
List1.AddItem TaskName
End If
End If
CurrWnd = GetWindow(CurrWnd, GW_HWNDNEXT)
DoEvents
Wend
End Sub
If you are running the install/update program from the workstation just use the FileCopy command;
FileCopy "\\WhatEverServer\my.exe" "C:\my.exe"
[Edited by tclere on 10-31-2000 at 03:38 PM]
-
Nov 1st, 2000, 02:49 PM
#12
Hyperactive Member
1. help< asked about a previous instance
2. That was my idea!!!!!!!!!!!!!!!!!!!!!
-
Nov 1st, 2000, 03:53 PM
#13
I did something very similar a year or so ago for an internal system I'd written for the company I work for. What I did was create an Update EXE which is passed the Current EXE and New EXE files and paths, it then copies the new one from the specified location over the old one and then runs it. then all I do is check the EXE dates within my application if there is a newer one in the remote location I call the Update EXE, i.e.
Code for Update.exe
Code:
'---------------------------------------------------
' modUpdate (modUpdate.bas)
'
' Copies a File From Source to Destination
' If successfull, the Destination File is Launched.
'
' Written By Aaron Young, September 1999
'---------------------------------------------------
'
' Last Modified: September 9th 1999
' By Aaron Young.
'
Option Explicit
Sub Main()
Dim sSrc As String
Dim sDst As String
Dim tTimer As Single
tTimer = Timer
While Timer - tTimer < 2
DoEvents
Wend
On Error GoTo UpdateError
'Extract Source and Destination Files from the Command Line
sSrc = Left(Command, InStr(Command, ",") - 1)
sDst = Mid(Command, Len(sSrc) + 2)
FileCopy sSrc, sDst
MsgBox "File Successfully Updated", vbInformation + vbOKOnly, "Update"
'Start the New File
Shell sDst, vbNormalFocus
UpdateError:
If Err Then MsgBox "Source: " & sSrc & vbCrLf & "Destination: " & sDst & vbCrLf & vbLf & Err.Description, vbCritical + vbOKOnly, "Error"
End Sub
Example usage in main app:
Code:
If FileDateTime(App.Path & "\" & App.EXEName & ".EXE") < FileDateTime(sUpdatePath & App.EXEName & ".EXE") Then
If MsgBox("There is an Newer Version of this Application Available for Download" & vbCrLf & "Update?", vbQuestion + vbYesNo, "Update") = vbYes Then
Shell sUpdatePath & "\Update.exe " & sUpdatePath & App.EXEName & ".EXE" & "," & App.Path & "\" & App.EXEName & ".EXE", vbNormalFocus
End
End If
End If
-
Nov 1st, 2000, 04:32 PM
#14
Member
determining if .exe is running
Use the API command "GetModuleHandle" and supply the module's name, where module name = FILENAME if the executable name is FILENAME.EXE.
Microsoft has a bunch of pages on API's so you can search the knowledge base their. Also. search http://www.northernlight.com for "getmodulehandle AND API", and you should get a lot of hits. You will have to declare the kernel32 api file in a .bas file attached to your code.
-lp
-
Nov 15th, 2000, 12:34 PM
#15
Thread Starter
Lively Member
Thanks to all you responded to this post.
Really appreciate the help provided by all.
Keep up the posting, newbie like me will continue to learn and perhaps one day, I'll be able to help others like you did here.
Sincerely yours,
Patrice B. 
Information System Analyst
SAS 9.1.3, VB6 SP6, VB.Net 2003, SQL7.0/2000
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|