#182136 - 2007-10-31 05:56 PM
Re: multi threading
[Re: Lonkero]
|
ChristopheM
Hey THIS is FUN
   
Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
|
first sorry for my english.
Hello lonkero,
i disagree with you about process on windows. (pre-requisite : pskill.exe and procexp.exe from sysinternals for some tests) 1) a process child doesn't end if parent dies. Do a very simple test : from desktop, start the task manager from the task manager, start a command line (cmd.exe) at this point, you have the following tree explorer.exe
taskmanager.exe
cmd.exe Now, in the commandline box, if you execute "pskill explorer", you lost the desktop but task manager and cmd are still alive !!!
2) start a process with RUN in a kix script doesn't start a new process tree. The process started is a child of kix32 (or wkix32). Look at the simple code below : run %systemroot%+"\system32\notepad.exe"
? "== script not ended =="
gets $x Now start procexp.exe. You will see that notepad is a child of kix32, which is a child of explorer. If you end the kix script by pressing any key, notepad is still here but has no parent anymore !!!
3) to come back to jeroen's problem, i suggest to use run "psexec ..." but add -d option to psexec (Don't wait for process to terminate (non-interactive)). The result depends on the number of hosts to scan. At my office, i use KiXtart every day for login script, administration and so on... but i have about 4000 workstations to scan and in this case, KiXtart is not enough powerfull (yes, it is possible to find limit to kix, hard but possible) !!!
So, i have developped with Delphi a program to execute the "unkixable" dirty side of the job. Here is what it is doing :
- reads hosts from a text file
- ping a host with a native win32 component (can process 4000 host in about 30 seconds. this is much faster that pings in kix with ping.exe or with WMI )
- if a host responds, start a new thread that starts a sub-process (exe, vbs, kix, cmd,...) and can wait or not the end of this process. The number of simultaneous threads can be limited to prevent the OS to freeze.
the sub-process can be started with runas.
Here is an example on the ini file :[OPTIONS]
Ping-TTL=32
Ping-TimeOut=10
Ping-DataSize=64
Ping-NbReply=2
PendingPingsMax=128
batch=false
Log=true
Logfile=<your logfile name>
HostFile=<file name of file containing the list of hosts to scan>
cmdsection=<name of the ini section that describe job to do for each host. See Command section below>
[Command]
runas=false / true
username=xxxx
userdomain=yyyy
userpassword=zzzz
cmdline=kix32 child.kix $hostname=#hostname# $user=#username# $domain=#userdomain# $pwd=#userpassword#
currentdirectory=<current directory for the started subprocess>
WaitForTerminate=true
KillAfterTimeout=false
Timeout=5000
Hide=true
Activate=false PendingPingsMax is the maximum number of simultaneous threads.
KillAfterTimeout is used if WaitForTerminate is true Timeout is the delay to kill subprocess when KillAfterTimeout is true
Hide allows to mask the subprocess window Activateallows to activate the subprocess window if it is not hidden
CommandLine is the exact commandline you want to start BUT #hostname#, #username#, #userdomain# and #userpassword# are replaced at execution by current values.
if CmdSection or CommandLine are not defined, the tool only pings hosts (just see if hosts are alive).
Usually, this tool allows me to start job on remote hosts from one central point. Each host writes log file on a central shared folder. If somebody is interested by this tool, i can send it by mail ("only" 803 kb for the .exe). And sorry if i have been a bit long !!!
_________________________
Christophe
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 858 anonymous users online.
|
|
|