Page 1 of 1 1
Topic Options
#127622 - 2004-10-08 06:02 PM Problem publishing SW list using WMI Win32_Product
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Hi.

Env:
Win 2000 SP4
Kixart 4.22
KixForms 2.3

Trying to adapt Inquisitor for my use, found some problems
which I need some guide ness:

$pc = $Windows.Items.Add("Apps")
$pc.SubItems(1).text = WMIQuery("","Win32_Product",$TextBox4.Text)[0]
$WindowsPBar.value = $WindowsPBar.value + 1

Want to use WMI Win32_Product to publish a list of installed softwares, Name, Version, identifynignumber and installed date, in a TabControl form.

And also the Printer part is not working:

$printers = WMIQuery("DriverName","Win32_Printer",$TextBox4.Text,"SystemName",$TextBox4.Text)
For Each $p In $printer
$pc = $Hardware.Items.Add("Printer")
$pc.SubItems(1).text = $p
Next

My last wonder is if its possible to edit a readed value listed in a TabControl form:

$pc = $IntExp.Items.Add("ProxyServer")
$pc.SubItems(1).text = ReadValue('\\'+$TextBox4.Text+'\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings','ProxyServer')
$IntExpPBar.Value = $IntExpPBar.Value + 1

Now when the "Proxy Server" value is readed from target registry and listded i Tab Control form, I want to change the "Proxy Server" value to something esle and make it write the new value on target registry.

Is it possible to put this functionality into the TabControl?

Grateful for any feedback!

Not a scripter
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#127623 - 2004-10-08 08:14 PM Re: Problem publishing SW list using WMI Win32_Product
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
About the printer part, i'm not sure if it was just a typo when you posted, but shouldn't it be

Code:

For Each $p In $printers

_________________________
Eric

Top
#127624 - 2004-10-09 09:04 PM Re: Problem publishing SW list using WMI Win32_Product
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
yeap ... it should be "printers" with "s". hummm, to much script lines and im getting dizzy...

But what about other parts? any ideas? can u help?

Still
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#127625 - 2004-10-09 09:56 PM Re: Problem publishing SW list using WMI Win32_Pro
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Can you restate what it is your trying to do. I get the impression you want to list some things in a ListView (embedded in a TabControl), and that once listed, you want to be able to let the "user" change a value, then have that value written back to the registry ?

-Shawn

Top
#127626 - 2004-10-09 10:19 PM Re: Problem publishing SW list using WMI Win32_Product
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Looking at the part for "Win32_Product".

I think your WMI_Query call is not correct. You have a null first parameter. I think you should have something there. Also I think you need to process all products found, not just the first as signified by the [0]

Code:

$stuff = WMIQuery("Caption","Win32_Product")
for each $thing in $stuff
? $thing
next

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#127627 - 2004-10-09 10:53 PM Re: Problem publishing SW list using WMI Win32_Pro
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Yes, Shawn that is correct. Sorry my english (is like the scripting) at beginners' level!

I tired to discribe 3 diffrent problems I have with above codes.

- First (List of installed apps on target machine)
I dont get any value listed in the TabControl listview when I run the WMI query state.
WMIQuery("","Win32_Product",$TextBox4.Text)[0]

- Second (List of installed Printers on target machine)
The same, the list is empty.

- Third (Edit a published value in the TabContol listview)
Is it possible to edit a readed value in the TabControl listview and then push it out to overwrite the target registry value, while operating in same Tabcontrol listview.

Normaly I dont have time (or opportunity for that matter!) to dig me deep in scripting issues,(but would like to do much more, if I had the brain and time). C is a simple helprunner!

Thanks in advance
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#127628 - 2004-10-09 11:03 PM Re: Problem publishing SW list using WMI Win32_Pro
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Howard, yes that will work. if I use "?"

But how do I list each pruduct line after line in the Form's TabControl listview?
For each readed product, it has to create a line with the Name, version, installed date and identifynignumber.

I think it must use the "Items.Add" for each pruduct, or?


Edited by 1984 (2004-10-09 11:04 PM)
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#127629 - 2004-10-10 12:03 AM Re: Problem publishing SW list using WMI Win32_Pro
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
This is the code to get the data you want. I sadly have never written a Kixforms script so I can help you load the Tab control.

I have provided you the KiXtart variables that you can feed into the Kixform control. You may know how to do that or someone else may be able to assist you.
Code:
$objWMI = GetObject("winmgmts:{impersonationlevel=impersonate}!//" + @WKSTA)
$Products = $objWMI.ExecQuery("select Name, Version, InstallDate, IdentifyingNumber from Win32_Product")
For Each $item In $Products

$Name = $item.Name
$Version = $item.Version
$InstallDate = $item.InstallDate
$IdentifyingNumber = $item.IdentifyingNumber


? $Name
? $Version
? $InstallDate
? $IdentifyingNumber
?
Next
$objWMI = 0

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#127630 - 2004-10-10 12:51 AM Re: Problem publishing SW list using WMI Win32_Pro
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ja, give me a few minutes to whip-up an example, be right back.

Top
#127631 - 2004-10-10 01:10 AM Re: Problem publishing SW list using WMI Win32_Pro
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Ok, using Howard's code as a base, here it is "wrapped-up" in a ListView, inside a TabControl, in a Form ... in the FILE menu, select "Load Products" to load the products into the ListView ... we can talk about updating the listview later, after you study this code ...

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()
$Form.ClientSize = 400,400

$MainMenu = $System.MainMenu

$FileMenu = $MainMenu.MenuItems.Add("File")
$LoadMenu = $FileMenu.MenuItems.Add("Load Products")
$LoadMenu.OnClick = "LoadClick()"

$ExitMenu = $FileMenu.MenuItems.Add("Exit")
$ExitMenu.OnClick = "quit"

$Form.Menu = $MainMenu

$TabControl = $Form.TabControl()
$TabControl.Dock = "Fill"

$TabPage = $TabControl.TabPages.Add("Products")

$ListView = $TabPage.ListView()
$ListView.Dock = "Fill"

$Column = $ListView.Columns.Add("Name")
$Column = $ListView.Columns.Add("Version")
$Column = $ListView.Columns.Add("InstallDate")
$Column = $ListView.Columns.Add("IndentifyingNumber")

$Form.Center()
$Form.Show()
While $Form.Visible
$= Execute($Form.DoEvents)
Loop

Exit 1

Function LoadClick()

Dim $objWMI, $products, $product, $item

$objWMI = GetObject("winmgmts:{impersonationlevel=impersonate}!//" + @WKSTA)

$products = $objWMI.ExecQuery("select Name, Version, InstallDate, IdentifyingNumber from Win32_Product")

$ListView.Items.Clear()
$Form.Cursor = 11
$ListView.BeginUpdate()

For Each $product In $products

$item = $ListView.Items.Add($product.Name)
$item.SubItems(1).Text = $product.Version
$item.SubItems(2).Text = $product.InstallDate
$item.SubItems(3).Text = $item.IndentifyingNumber

$= $Form.DoEvents(1) ;; refresh gui while loading values

Next

$ListView.EndUpdate()
$Form.Cursor = 0

$objWMI = 0

EndFunction



Top
#127632 - 2004-10-10 01:48 AM Re: Problem publishing SW list using WMI Win32_Pro
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Wow, thanks a lot guys, I will check it and get back to u.

/C
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#127633 - 2004-10-10 04:06 AM Re: Problem publishing SW list using WMI Win32_Pro
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Oh yea

I merged it to my script, some adaptation and it works! Thanx a lot.

One thing: the "IndentifyingNumber" list is empty. Seems not to publish anything. Strange....


Now my last question:

-Edit a published value in the TabContol listview

Target is readed and listed:

ReadValue('@WKST+'\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings','ProxyServer')

Now I want to changed the "Proxy Server" value to something else, by clicking on readed value in the listview window, delete and enter new key value and then make it write the new value back to registry.

Is it possible?

/C
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#127634 - 2004-10-10 04:36 AM Re: Problem publishing SW list using WMI Win32_Pro
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
IndentifyingNumber should be IdentifyingNumber ... just a typo. Here's a changed version of the above script if you want to change a value in the listview. If you need to actually remove and re-insert a record, thats a different story.

Code:

Break On

$System = CreateObject("Kixtart.System")

$Form = $System.Form()
$Form.ClientSize = 400,400

$MainMenu = $System.MainMenu

$FileMenu = $MainMenu.MenuItems.Add("File")
$LoadMenu = $FileMenu.MenuItems.Add("Load Products")
$LoadMenu.OnClick = "LoadClick()"

$ExitMenu = $FileMenu.MenuItems.Add("Exit")
$ExitMenu.OnClick = "quit"

$Form.Menu = $MainMenu

$TabControl = $Form.TabControl()
$TabControl.Dock = "Fill"
$TabPage = $TabControl.TabPages.Add("Products")

$ListView = $TabPage.ListView()
$ListView.Dock = "Fill"
$ListView.OnDoubleClick = "ListViewDoubleClick()"

$Column = $ListView.Columns.Add("Name")
$Column = $ListView.Columns.Add("Version")
$Column = $ListView.Columns.Add("InstallDate")
$Column = $ListView.Columns.Add("IdentifyingNumber")

$Form.Center()
$Form.Show()
While $Form.Visible
$= Execute($Form.DoEvents)
Loop

Exit 1

Function LoadClick()

Dim $objWMI, $products, $product, $item

$objWMI = GetObject("winmgmts:{impersonationlevel=impersonate}!//" + @WKSTA)

$products = $objWMI.ExecQuery("select Name, Version, InstallDate, IdentifyingNumber from Win32_Product")

$ListView.Items.Clear()
$Form.Cursor = 11
$ListView.BeginUpdate()

For Each $product In $products

$item = $ListView.Items.Add($product.Name)
$item.SubItems(1).Text = $product.Version
$item.SubItems(2).Text = $product.InstallDate
$item.SubItems(3).Text = $product.IdentifyingNumber

$= $Form.DoEvents(1) ;; refresh gui while loading values

Next

$ListView.EndUpdate()
$Form.Cursor = 0

$objWMI = 0

EndFunction

Function ListViewDoubleClick()

Dim $version, $newVersion

$version = $ListView.SelectedItem.SubItems(1).Text

$newVersion = $System.InputBox.Show("Enter new version","Script",$Version)

If $newVersion

$ListView.SelectedItem.SubItems(1).Text = $newVersion

Endif

EndFunction



Top
#127635 - 2004-10-10 02:24 PM Re: Problem publishing SW list using WMI Win32_Pro
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Yes, see WRITEVALUE and monitor the text e.g. via OnLostfocus for changes ot the original value. You can then write the new value back to the registry.
_________________________
There are two types of vessels, submarines and targets.

Top
#127636 - 2004-10-17 04:55 PM Re: Problem publishing SW list using WMI Win32_Pro
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
I'll tried to use your code and adapt it to mine, but no success :-( .
I need to restate what im trying to do:

I have a TabControl with 4 TabPage. "Hardware", "Software", "OS Details" and "Software"
In the "OS Details" when the "OS Details Update" button is clicked it will read several registry key values and publish the 2 columns "Object" and "Value" in the ListView for "OS Details" .

e.g.
Object -------------------- Value
ProxyServer -------------- www.proxy-server.com
SystemPath --------------- %SystemRoot%\system32;%SystemRoot%;C:\Program Files\ATI Technologies\ATI Control Panel;

and so on.....

So far so good.

Now I want to make some changes to readed values in the 2nd column "Value":

e.g double click on "Value" column for "SystemPath", remove the part "C:\Program Files\ATI Technologies\ATI Control Panel;".
Then Changes the "www.proxy-server.com" to "www.pserver.com".

And when I have done all changes push a button and write back the changes to to targets regisrty keys.

Here is the code i use:

;************* TABCONTROL1 **************
$TabControl1 = $Form.Controls.TabControl()
$TabControl1.Bounds = 15,175,460,300
$TabControl1.FontSize = 8
$TabControl1.FlatStyle = 2

$TabPage3 = $TabControl1.TabPages.Add
$TabPage3.Text = " OS Details"

;************* OS Details**************
$OSD = $TabPage3.Controls.ListView
$OSD.AllowColumnReorder = "True"
$OSD.Anchor = 5
$OSD.AutoArrange = "False"
$OSD.BackColor = 255,255,255
$OSD.BorderStyle = 2
$OSD.CheckBoxes = "False"
$OSD.Enabled = "True"
$OSD.FontBold = "False"
$OSD.FontItalic = "False"
$OSD.FontName = "Tahoma"
$OSD.FontSize = 8
$OSD.FontUnderline = "False"
$OSD.ForeColor = 0,0,0
$OSD.FullRowSelect = "True"
$OSD.GridLines = "True"
$OSD.Height = 225
$OSD.HeaderStyle = 2
$OSD.HideSelection = "True"
$OSD.LabelEdit = "True" ; <---- If "True" I can change values for first column "Object". But it is not here the changes should be!!)
$OSD.LabelWrap = "False"
$OSD.Left = 12
$OSD.MultiSelect = "False"
$OSD.TabStop = "False"
$OSD.Tag = ""
$OSD.ToolTipText = ""
$OSD.Top = 15
$OSD.View = 1
$OSD.Visible = "True"
$OSD.Width = 425

$=$OSD.Columns.Add("Object",150) ; <--------- First column, e.g. "ProxyServer" (Not to be changed!)
$=$OSD.Columns.Add("Value",200) ; <--------- 2nd column, e.g. "www.proxy-server.com" (Here i want to changed listed value, after its published)
;*************************************

;************* OS Details Update **************
$OSDUpdate = $TabPage3.Controls.ToolButton
$OSDUpdate.Anchor = 5
$OSDUpdate.TextAlign = 32
$OSDUpdate.Enabled = "False"
$OSDUpdate.FlatStyle = 2
$OSDUpdate.FontBold = "False"
$OSDUpdate.FontItalic = "False"
$OSDUpdate.FontName = "Tahoma"
$OSDUpdate.FontSize = 8
$OSDUpdate.FontUnderline = "False"
$OSDUpdate.ForeColor = 0,0,0
$OSDUpdate.Height = 24
$OSDUpdate.icon = 5
$OSDUpdate.Left = 415
$OSDUpdate.Style = 1
$OSDUpdate.TabStop = "True"
$OSDUpdate.Tag = ""
$OSDUpdate.Text = ""
$OSDUpdate.ToolTipText = ""
$OSDUpdate.Top = 245
$OSDUpdate.Visible = "True"
$OSDUpdate.Width = 22
$OSDUpdate.OnClick = "OSDC()"
;*************************************

Function OSDC()

$OSD.Items.Clear

$pc = $OSD.Items.Add("ProxyServer")
$pc.SubItems(1).text = ReadValue('\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings','ProxyServer')

$pc = $OSD.Items.Add("SystemPath")
$pc.SubItems(1).text = ReadValue('\HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment','Path')

;..... and so on

$OSDUpdate.pushed = "False"

EndFunction

What 2 do?
/C
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
#127637 - 2004-10-18 09:54 AM Re: Problem publishing SW list using WMI Win32_Pro
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, I had to reply as didn't at first glance see a single proper readline!
you should decide would you like to go with local or remote but neither of your previous lines will work (like you know)

so, for local readline:
$ProxyServerValue=ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings','ProxyServer')

and for remote:
$that_system="pcmypc"
$ProxyServerValue=ReadValue('\\'+$that_system+'\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings','ProxyServer')
_________________________
!

download KiXnet

Top
#127638 - 2004-10-18 09:56 AM Re: Problem publishing SW list using WMI Win32_Pro
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, and if shawn hasn't done something behind my back, that editing you want is not supported by listview.
_________________________
!

download KiXnet

Top
#127639 - 2004-11-17 09:06 PM Re: Problem publishing SW list using WMI Win32_Pro
1984 Offline
Starting to like KiXtart

Registered: 2003-08-14
Posts: 150
Tahnx Jooel :-)
since the editing I want is not supported by listview, we have to skip...However good enough for me.
Thanx Shawn and other for your help.

Case closed! :-)
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"

Top
Page 1 of 1 1


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

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.081 seconds in which 0.024 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