Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pravin Pawar
  Where is Pravin Pawar?
 Nashik
 India
 Pravin Pawar
 Tags
Subject: Try to Terminate Exe from LAN
Thread ID: 416366 Message ID: 416366 # Views: 55 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Sunday, December 28, 2014 12:20:43 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


*************

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