Page 1 of 1 1
Topic Options
#71625 - 2002-11-17 11:55 AM ryan, about your question in wmiquery()
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000117;p=1#000024

that was no good place to go as udf-library is "holy" (abc's of kixtart board etiquette in faq could be read)

anyway, to answer.
you code is wrong on the part of that execute.
you typed:
$Nul = Execute("$Val1=172.16.88.100")

when it should be:
$Nul = Execute("$$Val1=172.16.88.100")

as $ is special char and if wanted to pass in string, it needs to be doubled.

cheers.
_________________________
!

download KiXnet

Top
#71626 - 2002-11-18 12:06 AM Re: ryan, about your question in wmiquery()
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
actually, to make it really correct, it should be:
$Nul = Execute("$$Val1='172.16.88.100'")

as ip is not number but string.
_________________________
!

download KiXnet

Top
#71627 - 2002-11-18 12:14 AM Re: ryan, about your question in wmiquery()
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
Thanks for your reply! And yes this works.

But back to this query:

WMIQuery("DNSHostName", "Win32_NetworkAdapterConfiguration", @WkSta, "IPEnabled", "TRUE")

WMIQuery("IPAddress", "Win32_NetworkAdapterConfiguration", @WkSta, "IPEnabled", "TRUE")

It returns the hostname, but doesn't return the IPAddress!

Greetz

Top
#71628 - 2002-11-18 12:21 AM Re: ryan, about your question in wmiquery()
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what os?
_________________________
!

download KiXnet

Top
#71629 - 2002-11-18 12:22 AM Re: ryan, about your question in wmiquery()
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
Windows 2000 Professional UK SP2
Top
#71630 - 2002-11-18 12:24 AM Re: ryan, about your question in wmiquery()
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, then we have to wait wmi-gurus to show up.

anyway, why you don't use @ipaddress0 ?
_________________________
!

download KiXnet

Top
#71631 - 2002-11-18 12:45 AM Re: ryan, about your question in wmiquery()
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
I use this script to pull info from other network clients with WMI installed.

I still think it has something to do with Execute().
code:
$=execute("$$value = $$objInstance.$what")

I can't put ' quotes around the second part in this case.

Let's see what others may find.

Thanx anyway, Ryan

Top
#71632 - 2002-11-18 12:54 AM Re: ryan, about your question in wmiquery()
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, what is the value and $what?
I quess I'm one of the most exchaustive executers and still, I have had no problem with it.
_________________________
!

download KiXnet

Top
#71633 - 2002-11-17 03:46 PM Re: ryan, about your question in wmiquery()
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I think that the issue is that "IPAddress" is "string array" and not a standard string.

quote:
IPAddress
Data type: string array
Access type: Read-only

Array of all of the IP addresses associated with the current network adapter.

Example: "155.34.22.0"

I don't see where The UDF handles such a data type. I agree that the statement you reference is most likely the issue. I think that the "$$objInstance.$what" needs to be evaluted as to variable type and further processed if necessary. (wild-ass guess)

[ 17. November 2002, 15:59: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71634 - 2002-11-17 03:57 PM Re: ryan, about your question in wmiquery()
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This modified WMIQuery (WMIQuery2) addresses your need.
code:
FUNCTION WMIQuery2($what,$from,optional $computer,optional $where, optional $x)
dim $strQuery, $objEnumerator, $value
if not $computer $computer="@WKSTA" endif
$strQuery = "Select $what From $from"
if $where and $x $strQuery = $strQuery + " Where $where = '$x'" endif
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer")
if @error exit 1 return endif
$objEnumerator = $SystemSet.ExecQuery($strQuery)
For Each $objInstance in $objEnumerator
If @Error = 0 and $objInstance <> ""
$=execute("$$value = $$objInstance.$what")
Select
case VarType($value) = 8204
for each $x in $value
$WMIQuery2="$x"+"|"+"$WMIQuery2"
next
case VarType($value) = 8
$WMIQuery2="$value"+"|"+"$WMIQuery2"
case 1
$WMIQuery2 = "Unhandled data type returned: " + VarTypeName($value) +
"(" + VarType($value) + ")"
EndSelect
Endif
Next
$WMIQuery2=left($WMIQuery2,len($WMIQuery2)-1)
exit @error
ENDFUNCTION



[ 17. November 2002, 17:31: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71635 - 2002-11-18 03:56 PM Re: ryan, about your question in wmiquery()
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
good job Howard... I had wanted to get around to doing that...

Did you want to post it seperately, or have me update the original?

code:
$ip=wmiquery2("IPAddress",	"Win32_NetworkAdapterConfiguration",@wksta,"IPEnabled","True")
$sn=wmiquery2("IPSubnet", "Win32_NetworkAdapterConfiguration",@wksta,"IPEnabled","True")
$gw=wmiquery2("DefaultIPGateway","Win32_NetworkAdapterConfiguration",@wksta,"IPEnabled","True")
$ma=wmiquery2("MACAddress", "Win32_NetworkAdapterConfiguration",@wksta,"IPEnabled","True")

? $ip
? $sn
? $gw
? $ma



[ 18. November 2002, 15:57: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71636 - 2002-11-18 03:59 PM Re: ryan, about your question in wmiquery()
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I think it would be better to have you update the original. That way there is only one UDF meaning less confusion on the part of users.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71637 - 2002-11-19 02:13 AM Re: ryan, about your question in wmiquery()
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
This Howard is good! Excellent!

I'm so glad with the solution. I couldn't find the real problem.

Thanx y'all, 4 helping each other out.

Ryan

Top
#71638 - 2002-11-19 02:45 AM Re: ryan, about your question in wmiquery()
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
ryan, glad that I could help.

The board is dead tonight. Do you have any other problem(s) you need help resolving?
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71639 - 2002-11-19 04:30 AM Re: ryan, about your question in wmiquery()
Ryan Offline
Fresh Scripter

Registered: 2001-11-11
Posts: 42
Loc: the Netherlands
Hey Howard,

I'm trying 2 find a way, 2 automate a dial-up connection. All i found till now is the rasphone options and the dialup-script options. Works great but doesn't disconnect the line. But since I found KiXtart & COM match great..., yeah u know were i'm heading 2! Searched the net, but nothing yet!

Well hope u can help me, or at least have some ideas!

Groetjes Ryan

Top
#71640 - 2002-11-19 04:40 AM Re: ryan, about your question in wmiquery()
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Sorry, don't have any experience in that area, but I will be looking for anything that may help.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71641 - 2002-11-19 06:18 PM Re: ryan, about your question in wmiquery()
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
If you're using rasphone to initiate the connection, you can use rasphone to disconnect it...
code:
shell 'rasphone.exe -h "Name of Dial-up Connection"'


Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.064 seconds in which 0.029 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org