 |
|
|
 |
|
 |
Hi, I would like to have a look at the source code if you don't mind, but I can't get the link (http://e.domaindlx.com/DotNetGroup/projects/ExecuteIE/programExecuter/ExecuteIE.zip) to work with ether .zip or .ziq. Thanks!!
~Brendan Jensen
Brendan@BrendanJensen.com
|
|
|
|
 |
|
|
 |
|
 |
http://e.domaindlx.com/DotNetGroup/projects/ExecuteIE/programExecuter/ExecuteIE.ziq
rename ziq to zip ,
try and tell
Tareq Gamal
Wellcome
|
|
|
|
 |
|
 |
You Application is very nice but has some problems with closing applications. Maybe because ProcessName property holds an executable file name that does not include the .exe extension or the path and holds up to fifteen characters only. In you code you passed application name with exe extension so you system could not find it.
Maybe you can start processes by Shell command and store somewhere process ID so in that case you can check if process created by you exists and close only this one?
Janusz
|
|
|
|
 |
|
 |
yes u are right ,
it's one of the main problems in the program , that When open program : for example IE, then it's time to Exit it .., it Kill All running IE tasks (Windows)Becaise it kill every IE process ,
Sure it's silly .., but as u said the solution is getting the ID of the Specefied process I'll start .., but It wasnt important while I was Develop it , als I don't know how to get ID to start and Kill it if still Exist (by ID )
e
thank u for try and Motivate Me
Wellcome
|
|
|
|
 |
|
 |
You can use code like below:
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Integer, ByRef lpExitCode As Integer) As Integer
Const STILL_ACTIVE As Short = &H103S
Dim iProcID as integer
Dim iProcessHandle as integer
'start process and get process ID
iProcID = Shell(cCommandLIne, eAppStyle, True)
'next get process handle based on iProcID
iProcessHandle = OpenProcess(PROCESS_QUERY_INFORMATION, False, iProcID)
'to check if process is active you can use
Dim liReturnCode As Integer
GetExitCodeProcess(iProcessHandle, liReturnCode)
if liReturnCode=STILL_ACTIVE then you application is active and you can close it. If is different it is closed and you do not have to close it.
You can store handles to started processes in your application and setup a timer to check the state of processes you started and monitor them or close on specific time.
jpazgier
|
|
|
|
 |
|
 |
thank u I am tring it and tell u
thanks
|
|
|
|
 |
|
 |
i tried it but nothing Happened !
here is my Code :
it open the Explorer but 1procID always 0
also cCommandLIne ?? what is that
and what is "PROCESS_QUERY_INFORMATION" for
look for my code and tell what's wrong
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Integer, ByRef lpExitCode As Integer) As Integer
Public Function NewGo()
Dim cCommandLIne As String
Dim eAppStyle As String
cCommandLIne = "Explorer.exe http://msn.com"
Const STILL_ACTIVE As Short = &H103S
Dim iProcID As Integer
Dim iProcessHandle As Integer
'start process and get process ID
iProcID = Shell(cCommandLIne, eAppStyle, True)
TextBox1.Text = iProcID.ToString()
'next get process handle based on iProcID
' PROCESS_QUERY_INFORMATION
iProcessHandle = OpenProcess(0, False, iProcID)
TextBox1.Text = TextBox1.Text & iProcessHandle.ToString
'to check if process is active you can use
Dim liReturnCode As Integer
GetExitCodeProcess(iProcessHandle, liReturnCode)
End Function
welcome for any comments , Questions
-- modified at 19:12 Friday 27th January, 2006
|
|
|
|
 |
|
 |
I am sorry I missed some parts of code because I tried to give you a chence to search for it in WIN32 help. Below is updated version I hope it will work fine:
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
Public Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Integer, ByRef lpExitCode As Integer) As Integer
Const STILL_ACTIVE As Short = &H103S
Const PROCESS_QUERY_INFORMATION As Short = &H400S
Dim iProcID as integer
Dim iProcessHandle as integer
Dim eAppStyle As AppWinStyle
'start process and get process ID
iProcID = Shell(cCommandLIne, eAppStyle, True)
'next get process handle based on iProcID
iProcessHandle = OpenProcess(PROCESS_QUERY_INFORMATION, False, iProcID)
'to check if process is active you can use
Dim liReturnCode As Integer
GetExitCodeProcess(iProcessHandle, liReturnCode)
if liReturnCode=STILL_ACTIVE then you application is active and you can close it. If is different it is closed and you do not have to close it.
You can check exit Code for error code returned from application so based on this value you can check if it succed or failed succes is in most cases 0 other value error.
You can store handles to started processes in your application and setup a timer to check the state of processes you started and monitor them or close on specific time.
At the end is good to close handle by executing :
Call CloseHandle(iProcessHandle)
jpazgier
|
|
|
|
 |
|
 |
Hi Tareq,
It works nicely starting the process and runs the program in the specified intervals. However, it doesn't kill or close the program afterwards. So It keeps opening windows of the same program and one needs to close it manually.
By the way, in your example you indicated that 36000 is an interval of one hour - appearently its 36 seconds. So, in order to set it to 1 hour it should be 3,600,000.
Another thing, can you post the source files?
Anyway, thanks for a nice piece of code.
|
|
|
|
 |
|
 |
1st thank u for Motivation And try it ,
yes u have to increase to be 3,600,000 on the Txt file URL.txt on the "c:\" root
also I had the source code , but it didn't let me Upload it from Gmail anyhow :
I'll post it here dont worry
I'm very happy that u try ,
also I think it's fine in this version (Open then close / 1 hour ) also u can check And tell
thank u again ..waiting for your comment
Wellcome
|
|
|
|
 |
|
 |
I Finally found a solution to your Question about why it dosent kill the process ,
it's In the c:\Url.txt file
u can Set the process Name "if it is Internet Exeplorer"
to Iexeplore.exe
Because Explorer.exe Execute the Windows Explorer .., then Give it the url .., so windows Exeplorer pass it to "Internet exeplorer" Iexplore.exe
so it navigate to your site .,
so when close the process explorer .. it will not kill the website:->
hope this helps u ,
welcome for any comments , Questions
|
|
|
|
 |