WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

AppExist AppWaitClose Fail

 Keywords:  AppExist AppWaitClose RunWait fail return zero not found

Question:

I have scripts that run an executable with certain switches, but before it runs it has to make sure the executable is not already running. So I use AppExist to check for it and then AppWaitClose to make sure it is done before continuing to process (it has to pass some information to a window that pops up, so I can't use Run with the @WAIT option).

The script has been working fine until this past Friday. I have uninstalled Windows updates from that day to rule those out and then did a reboot. However, the issue still exists. The script has not been changed and the exe name I'm looking for has not changed. Any ideas as to what could make this stop working?

The OS is Windows Server 2003 and script is running with admin priviledges.

Answer:

My guess is that someone disabled performance monitoring.

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Miscellaneous+Performance~Monitoring~and~WinBatch.txt

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Functions+AppExist~Fails.txt

User reply:

There is no Disable Performance Counters in the registry. I can go into the Performance Monitor and add a counter on a process. The Local Security Policy is set for Administrators and Power Users to profile a single process, and Profile System Performance is set to Administrators. It would make sense that it is something with the Performance Monitors, but so far everything checks out.

When I used the Exctrlst Tool for Windows 2003, it shows all the Performance counters as enabled. There doesn't seem to be too much more to check in there.

I also ran the lodctr /R command and did a restart on the computer; however the script still doesn't work.

Answer:

I wonder if you are getting the exe name correct. Is it possible it changed?

It might be interesting to get a list of the processes running and write then out to a file. In the code where you have Appexist. I recommend adding the following code right after it. Like this:

;Make sure your application is running

DebugTrace(@On , 'C:\trace.txt')
exe = 'notepad.exe' ;Modify to use the exe you are looking for!
ret = AppExist(exe )

AddExtender("wwprc44I.dll")
list=tListProc()
data = StrReplace( list, @tab, @crlf )
FilePut( 'C:\proclist.txt', data )
Exit
Then post both the trace.txt and the proclist.txt here.

User Reply:

The process name has not changed. The program was not loaded/reloaded/updated anytime near when this began to happen.

The interesting thing I see from your code is that there are numbers and other things after all of the process names. That is similar to what I mentioned seeing in the Performance Monitor.You may be on to something here.

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

*** Debug Initialized ***

==============================
Tue 2/12/2008 11:15:58 AM
WinBatch 32 2007C
WIL DLL 5.14cen
F:\TEMP\test.exe
Windows platform: NT, version: 5.2, build: 3790 (Service Pack 1)
ErrorMode: @CANCEL
==============================

exe = 'stclient.exe'
(15) VALUE STRING => "stclient.exe"

ret = AppExist(exe )
(4172) VALUE INT => 0

----- Extender loaded: F:\TEMP\wproc34i.dll (file version: 10013,0,0,0)

AddExtender("wproc34i.dll")
(4187) VALUE INT => 1

list=tListProc()
(4218) VALUE STRING => "Idle|0	System_4|4	smss_420|420	csrss_524|524	winlogon_556|556	services_624|624	lsass_644|644	svchost_848|848	svchost_960|960	svchost_1032|1032	svchost_1072|1072	svchost_1140|1140	spoolsv_1348|1348	msdtc_1388|1388	DkService_1520|1520	svchost_1576|1576	inetinfo_1604|1604	CatTools_Service_1636|1636	Syslogd_Service_1816|1816	FrameworkService_1932|1932	svchost_192|192	smlogsvc_296|296	VMwareService_348|348	naPrdMgr_460|460	beremote_512|512	svchost_1000|1000	dmadmin_1024|1024	explorer_2252|2252	UpdaterUI_2356|2356	VMwareTray_2400|2400	VMwareUser_2412|2412	ctfmon_2436|2436	CatTools_Manager_2456|2456	svchost_3404|3404	wmiprvse_272|272	taskmgr_3332|3332	ReceiveImages_2664|2664	stclient_3844|3844	test_1108|1108"

data = StrReplace( list, @tab, @crlf )
(4218) VALUE STRING => "Idle|0
System_4|4
smss_420|420
csrss_524|524
winlogon_556|556
services_624|624
lsass_644|644
svchost_848|848
svchost_960|960
svchost_1032|1032
svchost_1072|1072
svchost_1140|1140
spoolsv_1348|1348
msdtc_1388|1388
DkService_1520|1520
svchost_1576|1576
inetinfo_1604|1604
CatTools_Service_1636|1636
Syslogd_Service_1816|1816
FrameworkService_1932|1932
svchost_192|192
smlogsvc_296|296
VMwareService_348|348
naPrdMgr_460|460
beremote_512|512
svchost_1000|1000
dmadmin_1024|1024
explorer_2252|2252
UpdaterUI_2356|2356
VMwareTray_2400|2400
VMwareUser_2412|2412
ctfmon_2436|2436
CatTools_Manager_2456|2456
svchost_3404|3404
wmiprvse_272|272
taskmgr_3332|3332
ReceiveImages_2664|2664
stclient_3844|3844
test_1108|1108"

FilePut( 'C:\proclist.txt', data )
(4234) VALUE INT => 748

Exit
(4234) VALUE INT => 0

--- Normal termination ---

;;;END OF JOB;;;

Answer:

Interesting. Those trailing #'s are PID values being shown in duplicate wherever the PID value is non-zero. Only the "Idle" pseudo-process has a zero PID, and its PID value is only shown a single time.
< process-name >[_< non-zero-PID >]| < PID >
It would appear that the process counter entry used by AppExist() & AppWaitClose() on your system has been altered in some way so as to cause it to report more information than just the process name. It's now including PID information. When you identify the proper registry key/value, you can compare it with one from a working system and then restore the value accordingly.

If you check out the following link, this may explain what is showing up with those process names: http://support.microsoft.com/kb/281884

User Reply:

That worked. I changed it to a value of 1 and I didn't have to reboot. The Process Monitor and the test script you gave me now work properly. Thanks for sticking with me on this. Now I just need to find out how it got changed.
Article ID:   W17408
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38