Home > Software engineering >  Vb SHELL access to the problem of pid, the second "~ ~ ~
Vb SHELL access to the problem of pid, the second "~ ~ ~

Time:09-18

In VB call an external application with SHELL for pid problem:

Private Sub Command1_Click ()
Pid=Shell (" C: \ Program Files \ Internet Explorer \ iexplore ", vbNormalFocus)
End Sub


First open in Windows 7 and XP is no problem,

But when click on the command1 button again, open the Windows task manager, found a strange problem:

Prerequisite browser are IE8
1, in Windows 7, Windows task manager new process pid ie do not tally with the return of pid;
2, in Windows XP, Windows task manager won't add the ie process;

So I cannot pid for IE next shut, strives for the solution (note that I want to open multiple browser Windows),

CodePudding user response:

Then watch carefully and accurately whether in XP or Windows 7 to run for the first time in the task manager will generate a new process, IE shell can also capture normal to
But the second and third run shell when there is a new IE process in task manager will be temporary, but immediately and disappeared,
Since process are gone, so won't be able to complete the specified window closed,

==================================================
Thinking: just click on the desktop the IE icon in the task manager will create a new process of IE, why can't in VB by shell?

CodePudding user response:

There is nothing wrong with machine measured.

CodePudding user response:

I try out, add/new can solve, that is,
Pid=Shell (" C: \ Program Files \ Internet Explorer \ iexplore exe/new ", vbNormalFocus)

But the problem comes again, this is the right to obtain the pid (follow-up process can also be closed), but at the same time open ie will have direct access to http://new, it should be how to write in here?

CodePudding user response:

Miserable is parameters can only/new writing, can't change - new, masters, how to solve?

CodePudding user response:

reference 4 floor Hqmy1994 response:
miserable is parameters can only/new writing, can't change - new, masters, how to solve?

Test, here I add - new,
IE "specific command line parameters are identified with a - symbol, is not to use" - "the beginning of the parameter estimates, it is considered to be a URL,
In addition, if just "test results", can try to add parameters: - nohome (start IE, open the "blank" window)

But I found a problem:
If start the new process, IE URL1 and specify it to open the url;
But enters URL1, it will be "automatically jump to the" URL2 happened (one or more "redirect"), in the end the new process of PID with "to start the process of PID" is not the same,

CodePudding user response:

 Shell "CMD/d taskkill/F/IM iexplore. Exe", vbHide 

CodePudding user response:

refer to 6th floor zhao4zhong1 response:
 Shell "CMD/d taskkill/F/IM iexplore. Exe", vbHide 

Don't understand, don't talk nonsense!!!!!!


Like you, is it not "cut all killed off"!!!!!! It is impossible is the effect of the "end of the specified process"!

CodePudding user response:

refer to the original poster Hqmy1994 response:
in VB call an external application with SHELL for pid problem:

Private Sub Command1_Click ()
Pid=Shell (" C: \ Program Files \ Internet Explorer \ iexplore ", vbNormalFocus)
End Sub


First open in Windows 7 and XP is no problem,

But when click on the command1 button again, open the Windows task manager, found a strange problem:

Prerequisite browser are IE8
1, in Windows 7, Windows task manager new process pid ie do not tally with the return of pid;
2, in Windows XP, Windows task manager won't add the ie process;

So I cannot pid for IE next shut, strives for the solution (note that I want to open multiple browser Windows),


I want to ask you about your
A, you above is an example using the shell open an external program, or is to open the ie
Second, if you pass the shell open ie, don't know what do you want to do the operation, or just to close? Because the program when you finished,
Three, if you want to turn on, get the pid, can try the function I gave you
Const the SYNCHRONIZE=& amp; H100000

Const INFINITE=& amp; HFFFFFFFF

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Declare the Function WinExec Lib "kernel32" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long



The Public Function ShellWait (SheStr As String) As Long

Dim pId As Long pHnd As Long

PId=Shell (SheStr, vbHide)

PHnd=OpenProcess (the SYNCHRONIZE, 0, pId)

If pHnd & lt;> 0 Then

Call WaitForSingleObject (pHnd, INFINITE)

Call the CloseHandle (pHnd)

End the If

ShellWait=pId

End the Function

Call way: pid=shellwait (" C: \ Program Files \ Internet Explorer \ iexplore ")

Four, if is to use the ie, suggest you use the webbrowser control, very convenient, just out of control

CodePudding user response:

The zeal of ash often thank you again, my problem solved, also, to share with you
my aim is to: use agents set up IP to brush flow, mainly is the IP quantity ha (purpose, presence of meaning, we will not pursue the ha )

1, the first step through the API access to the proxy IP;
2, set the IE agent services, access the specified page,

If using the webbrowser control, very comfortable, at first I did the same, in order to improve the efficiency, I also use multiple Windows to put the webbrowser control, each FORM FORM their own proxy IP, but this way the CNZZ, 51. La and other third party statistics is invalid (it is strange that the webbrowser control access my PHP program $_SERVER [' REMOTE_ADDR] show IP is the proxy IP, thinking for a long time didn't find the problem so give up)

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related