#111653 - 2004-01-12 08:41 PM
Odd error in KixForms app
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
Guys:
I'm having a strange problem with a large KixForms project. The tool queries a remote server via registry info and WMI and displays it in a form. One function reboots the server, monitoring it as it shuts down and restarts. When the server is back up ("up" = responds to ping, then returns an "xnet list" with no "start pending" results), the form is cleared and the function that queries the target and updates the form is called. At this point, the script exits with the following message:
Code:
ERROR : unexpected command! Script: D:\dev\SIT\smit.kxw Line : 954
If I comment out the clear/re-query function calls, no error occurs. Also, if I query another server, it succeeds. However, if I then query the server that was rebooted, the error occurs!
The line being referenced is the first of the WMIQuery() series of function calls. Code:
$HW_00 = WMIQuery('Manufacturer', 'Win32_ComputerSystem', $System)[0]
I'm at a loss as to why this function works the first time, works multiple times, works on another server after a reboot of a target, but fails any time a server rebooted via the tool reruns the query.
I'd post the code, but at 125K, it's a bit challenging. I'll zip/email it to anyone that wants to play with it, but I'm really wondering if there's something I'm missing with how WMI works, or possibly not properly clearing a WMI connection??
Thanks in advance,
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#111659 - 2004-01-13 04:02 AM
Re: Odd error in KixForms app
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
Yes, it is..
I didn't realize that was the problem - I had to dig through the code. I downloaded and used WMIQuery pretty much as-is, and it had worked very well until this project.
So, now - what do I do? It's a moral dilemma, no?
Do I modify the function to support NoVarsInStrings? Won't that cause scripts that don't specify this to fail? Or - do I check the NoVar setting on entry to the function, turn it off, then restore it before exiting the function?
Or - creative coding: Code:
; Get setting $RC = SetOption('NoVarsInStrings', 'On') ; Define "$" or "$$" $Dollar = IIf($RC = 'On', '$', '$$') ; Restore setting $RC = SetOption('NoVarsInStrings', $RC) ; Define EXE string $EXE = $Dollar + 'Varname' Execute $EXE
Granted, there are only a handful of functions that utilize the Execute statement, but its something to consider as my function library grows, and I grow more dependent on it.
Whadda ya think?
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#111665 - 2004-01-16 08:38 PM
Re: Odd error in KixForms app
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
Yeah, well - Les says tomato, I say tomatoE!
It's just another way to skin the same kat, but to me, referencing the $Dollar instead of the $Quote was more obvious when reading it later.
I agree on the KBP, which is why I'm testing every one of my functions in the lib to operate correctly with EXPLICIT and NoVarsInStrings both ON and OFF.
I am, however, back to my original problem. It worked at home, restarting a 2K3 server from an XP workstation, but at the office, restarting a 2K3 server from a 2K workstation fails with the same error message.
I'm rewriting the code to focus on two components - collecting information from the remote server, and tracking the reboot of the server, and eliminating all extraneous code.
What's wierd is that the information is collected once and displayed. Then, after issuing a reboot and monitoring the loss and restoration of Ping response, and then insuring that we can really communicate with the NetBIOS process, we repeat the entire data collection and display function. When the data is displayed, it fails.
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#111667 - 2004-01-17 07:26 PM
Re: Odd error in KixForms app
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
OK, different words, but that's the kind of thing I suspected in my first post. Is there some way to close / clear the cache?
Keep in mind, if I put a pause statement into the failing code just prior to the HWI() function (which calls WMIQuery repeatedly), and run a script that calls HWI() and just displays the results, it works. Separate environment and session, but it proves that the server responds to the HWI function. Allow the main prog to continue and it dies when trying to display the results of the HWI.
Further, if I comment out the code to re-query the server and then select another server, everything works, but if I then query the rebooted server, it fails with the same error.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 774 anonymous users online.
|
|
|