Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ali Koumaiha
  Where is Ali Koumaiha?
 Farmington Hills
 Michigan - Lebanon
 Ali Koumaiha
 To: Zia Mughal
  Where is Zia Mughal?
 Rawalpindi
 Pakistan
 Zia Mughal
 Tags
Subject: RE: Try to Terminate Exe from LAN
Thread ID: 416366 Message ID: 416432 # Views: 37 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Monday, December 29, 2014 3:24:07 PM         
   


> > 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
> >
> >
> > *************
>
> Respected Pravin,
>
> Already Mr.Neeraj and respected Jun provided best suggestion as alternative way to your existing.
>
> > My client Network with 145 of PC.
> > I have Shared my ERP Exe on Each PC. ( Map Network ).
>

> if you are running your .exe from mapped drive of server you have to terminate all multiple processes of your each user.
> otherwise you can't rename it or replace existing .exe.
>
> In your current native way of working:
> 1. you can create a dummy file or insert a record in a table, which is checked by procedure routine when you exe is loaded, if that file or record is true then exit/terminate immediate with indicating Message to user like "Closed for maintenance".
> 2. you add checkroutineformaintenance()= .t. then give Message to user to close its work immediate otherwise after some time interval "Quit" by force.
> 3. after your maintenace delete that maintenace file or record or set value of field to .f. for opening to work normal.
>
> Regards
>
> Zia Mughal
> Pcland Software inc. Pakistan
> http://www.pcland.com.pk
> http://pclandpk.blogspot.com


I like Zia's suggestion, however, i would use a text file and not a dbf file or record. It happened many times, where the DBF (assuming its a dbf back end), might get corrupted or something due to network failure or issue.

I use a TXT file, i call it "Shutdown.txt" and a timer that checks for it..

Again, exactly like Zia's suggestion, but a a text file



Ez Logic

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