Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: mk sharma
  Where is mk sharma?
 mumbai
 India
 mk sharma
 To: Greg Green
  Where is Greg Green?
 
 Georgia - United States
 Greg Green
 Tags
Subject: RE: Try to Terminate Exe from LAN
Thread ID: 416366 Message ID: 416480 # Views: 34 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Tuesday, December 30, 2014 6:40:08 AM         
   


> > Dear Experts,
> >
> > My client Network with 145 of PC.
> > I have Shared my ERP Exe on Each PC. ( Map Network ).
> >
> > When i want to Update Exe File on Server, i have to told all User to close the application. Every time EDP Person Call all the users and verify that they closed system or not..
> >
> > To avoid this ... i search a solution over the net .... and got a ready code...
> > Code work fine on Server ( Local Pc ... where it Run ) but not work ALL Network Pc.
> >
> > i am not able to understand what is the issue... and why user side exe was not terminating....
> >
> > Please see the Code.....
> > .....................
> >
> >
> > lcExeName = "notepad.exe" && Sample EXE Name
> >
> > * Is EXE running
> > ? IsExeRunning(lcExeName)
> > * Terminate EXE if it's running
> > ? IsExeRunning(lcExeName, .T.)
> > RETURN
> >
> > FUNCTION IsExeRunning(tcName, tlTerminate)
> > LOCAL loLocator, loWMI, loProcesses, loProcess, llIsRunning
> > loLocator = CREATEOBJECT('WBEMScripting.SWBEMLocator')
> > loWMI = loLocator.ConnectServer()
> > loWMI.Security_.ImpersonationLevel = 3 && Impersonate
> >
> > loProcesses = loWMI.ExecQuery([SELECT * FROM Win32_Process WHERE Name = '] + tcName + ['])
> >
> > llIsRunning = .F.
> > IF loProcesses.Count > 0
> > FOR EACH loProcess in loProcesses
> > llIsRunning = .T.
> > IF tlTerminate
> > loProcess.Terminate(0)
> > ENDIF
> > ENDFOR
> > ENDIF
> > RETURN llIsRunning
> >
> >
> > *************
>
> I do not require users to log off in order to update. I have a small program that is compiled to an EXE. The EXE then executes the 'real' program which is compiled as an APP file. The EXE first checks the server if a newer version of the APP is available based on file timestamp. If a newer version is found, it will notify the user to wait while the new version is copied to the local PC. Then the EXE program executes the APP file. My code for this is:
>
>
>
> *-***********************************************************************************************
> *-* Written by:  Gregory A. Green
> *-***********************************************************************************************
> *-* Main program
> *-*
> #DEFINE False .F.
> #DEFINE CRLF  CHR(13)+CHR(10)
> FUNCTION AppLoaderMain
> LOCAL lcUpdateDir, lcExistnFile, lcUpdateFile, lnFileFound, loForm, lcPath, lcResource
> LOCAL ARRAY laNetwkFile[1], laLocalFile[1]
> SET SAFETY OFF
> SET PROCEDURE TO DeclareWinAPI ADDITIVE
> lcPath     = ADDBS(GetConfigPath())
> lcResource = lcPath + "foxuser.dbf"
> SET RESOURCE TO (lcResource)
> ADDPROPERTY(_VFP, "TestMode", False)
> ADDPROPERTY(_VFP, "ProgramName", lcPath+"Program\"+GetString_VFP("Settings", "ProgramName"))
> lcUpdateDir = GetString_VFP("Settings", "UpdatePath")
> IF !EMPTY(lcUpdateDir) .AND. !EMPTY(lcUpdateDir)                     && Check for network program update
> 	lcExistnFile = FORCEEXT(_VFP.ProgramName, "app")
> 	lcUpdateFile = ADDBS(lcUpdateDir) + FORCEEXT(JUSTFNAME(lcExistnFile), "app")
> 	lnFileFound  = ADIR(laNetwkFile, lcUpdateFile)
> 	IF lnFileFound > 0
> 		lnFileFound = ADIR(laLocalFile, lcExistnFile)
> 		IF lnFileFound > 0
> 			DO CASE                                                  && Check if newer file on network
> 				CASE laNetwkFile[1, 3] > laLocalFile[1, 3]
> 					DO FORM DisplayMsgTopLevel WITH "Please Wait -- Updating Program File" NAME loForm
> 					INKEY(0.001, 'H')
> 					COPY FILE (lcUpdateFile) TO (lcExistnFile)
> 					loForm.Release()
> 
> 				CASE laNetwkFile[1, 3] = laLocalFile[1, 3]
> 					lnLocalFileTime = VAL(SUBSTR(laLocalFile[1, 4],1,2)) + (VAL(SUBSTR(laLocalFile[1, 4],4,2))/60) + (VAL(SUBSTR(laLocalFile[1, 4],7,2))/360)
> 					lnNetwkFileTime = VAL(SUBSTR(laNetwkFile[1, 4],1,2)) + (VAL(SUBSTR(laNetwkFile[1, 4],4,2))/60) + (VAL(SUBSTR(laNetwkFile[1, 4],7,2))/360)
> 					IF lnNetwkFileTime > lnLocalFileTime
> 						DO FORM DisplayMsgTopLevel WITH "Please Wait -- Updating Program File" NAME loForm
> 						INKEY(0.001, 'H')
> 						COPY FILE (lcUpdateFile) TO (lcExistnFile)
> 						loForm.Release()
> 					ENDIF
> 			ENDCASE
> 		ELSE
> 			DO FORM DisplayMsgTopLevel WITH "Please Wait -- Updating Program File" NAME loForm
> 			INKEY(0.001, 'H')
> 			COPY FILE (lcUpdateFile) TO (lcExistnFile)
> 			loForm.Release()
> 			WAIT CLEAR
> 		ENDIF
> 	ENDIF
> ENDIF
> IF FILE(lcExistnFile)                                                && Test for file existance
> 	DO (lcExistnFile)
> ELSE
> 	DO FORM DisplayMsgTopLevel WITH "Unable to locate the application file; Contact System Administrator" NAME loForm
> 	INKEY(5, 'H')
> 	loForm.Release()
> ENDIF
> ENDFUNC
> 


Thank you,

Form DisplayMsgTopLevel ?

Warm Regards,
mk.

ENTIRE THREAD

Try to Terminate Exe from LAN Posted by Pravin Pawar @ 12/28/2014 12:20:43 PM
RE: Try to Terminate Exe from LAN Posted by Mike Gagnon @ 12/28/2014 1:49:20 PM
RE: Try to Terminate Exe from LAN Posted by Neeraj Charne @ 12/28/2014 2:26:21 PM
RE: Try to Terminate Exe from LAN Posted by Jun Tangunan @ 12/29/2014 1:18:33 AM
RE: Try to Terminate Exe from LAN Posted by Neeraj Charne @ 12/29/2014 8:54:40 AM
RE: Try to Terminate Exe from LAN Posted by Jun Tangunan @ 12/30/2014 5:02:36 AM
RE: Try to Terminate Exe from LAN Posted by Zia Mughal @ 12/29/2014 8:08:15 AM
RE: Try to Terminate Exe from LAN Posted by Ali Koumaiha @ 12/29/2014 3:24:07 PM
RE: Try to Terminate Exe from LAN Posted by Greg Green @ 12/29/2014 10:16:21 PM
RE: Try to Terminate Exe from LAN Posted by mk sharma @ 12/30/2014 6:40:08 AM