Page 1 of 1 1
Topic Options
#128013 - 2004-10-17 01:58 AM Kixomatic 2.1.2 - now with Wkix32
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
took the liberty to slightly modify kixomatic.
sorry, just had to do it

the difference is that it should work now also with wkix32.
oh, and this version is unofficial one.
the 2.1 is the last version approved by the author!

changes in 2.1.2 (6th of july 2005)
- added support for executing script clicking run even if not kix associated (nasty lack it was)
- 2.1.2.1 accepts execution even if scriptdir a UNC path and no kix avail on path.

Code:

break on
if @scriptexe<>"wkix32.exe"
$nul=setconsole("hide")
endif
if not "\\"=left(@scriptdir,2)
go left(@scriptdir,2)
cd @scriptdir
endif

$Form = CreateObject("Kixtart.Form")
$Form.Caption = "KiXomatic 2.1.2"
$Form.ScaleHeight = 520
$Form.ScaleWidth = 650
$Form.Center

$PForm = CreateObject("Kixtart.Form")
$PForm.Caption = "Loading WMI Classes..."
$PForm.Width = 250
$PForm.Height = 60
$PForm.BorderStyle = 3
$PForm.Center
$PForm.controlbox = 0

$PBar = $PForm.ProgressBar
$PBar.Size = 230,15
$PBar.Style = "1"
$PBar.Center

$Frame = $Form.PictureBox(,,,$Form.ScaleWidth,$Form.ScaleHeight)
$Frame.BorderStyle = 2

$lstClass = $Frame.ComboBox(,20,15,450)
$lstClass.Additem ("Begin by selecting a class")
$lstClass.Sorted = 1
$lstClass.Value = "Begin by selecting a class"
$lstClass.OnClick = "ChooseClass()"
$nul = EnumClasses()

$cmdRun = $Frame.CommandButton("Run", 475,15,35,20)
$cmdSave = $Frame.CommandButton("Save",515,15,35,20)
$cmdOpen = $Frame.CommandButton("Open",555,15,35,20)
$cmdQuit = $Frame.CommandButton("Quit",595,15,35,20)
$cmdRun.Onclick = "RunScript()"
$cmdSave.Onclick = "SaveScript()"
$cmdOpen.Onclick = "OpenScript()"
$cmdQuit.Onclick = "$$Form.Hide"
$cmdRun.Tooltip = "Run the script"
$cmdSave.Tooltip = "Save the script"
$cmdOpen.Tooltip = "Open a saved script"
$cmdQuit.Tooltip = "Quit KiXomatic"
$cmdRun.Enabled = 0
$cmdSave.Enabled = 0

$TextBox = $Frame.TextBox(,20,37,610,460)
$TextBox.AcceptsReturn = True
$TextBox.MultiLine = True
$TextBox.Fontname = "Courier New"
$TextBox.Fontsize = "8"
$TextBox.Scrollbars = 2
If $Form.Build<34 $TextBox.MousePointer = 3 EndIf
$TextBox.Hide

$Form.Show

While $Form.Visible
$nul=Execute($Form.DoEvents)
Loop

QuitScript()
Exit 1

Function EnumClasses()
Dim $Max
$PForm.Show
$objWMIService = GetObject("winmgmts:\\.\root\cimv2")
For Each $objClass in $objWMIService.SubclassesOf() $Max = $Max + 1 Next
$PBar.Max = $Max
For Each $objclass in $objWMIService.SubclassesOf()
$PBar.Value = $PBar.Value + 1
$IsQ = 0
If instr($objClass.Path_.Class,"WIN32_")
For Each $Qualifier in $objClass.Qualifiers_
If Instr($Qualifier.Name, "ASSOCIATION")
$IsQ = 1
Endif
Next
If $IsQ = 0
$lstClass.Additem ($objClass.Path_.Class)
Endif
Endif
Next
$PForm.Hide
$objWMIService = 0
EndFunction

Function ChooseClass()
Dim $Max
If $lstClass.Value <> "Begin by selecting a class"
$Class = $lstClass.Value
$Form.MousePointer = 11
$PForm.Caption = "Customizing Script..."
$PBar.Value = 0
$PForm.Center
$PForm.Show
$Textbox.Show
$TextBox.Text = ""
$cmdRun.Enabled = 0
$cmdSave.Enabled = 0
$objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
$objClass = $objWMIService.Get($Class)
For Each $objProperty in $objClass.properties_ $Max = $Max + 1 Next
$PBar.Max = $Max
$Script = 'Break On' + @CRLF
$Script = $Script + '$$strComputer = "."' + @CRLF
$Script = $Script + '$$objWMIService = GetObject("winmgmts:\\" + $$strComputer + "\root\cimv2")' + @CRLF
$Script = $Script + '$$colItems = $$objWMIService.ExecQuery("Select * from $Class",,48)' + @CRLF
$Script = $Script + 'For each $$objItem in $$colItems' + @CRLF
For Each $objProperty in $objClass.properties_
$PBar.Value = $PBar.Value + 1
$Prop = $objProperty.name
If instr(WMIQuery($Prop,$Class),"$$value")
$Script = $Script + ' For each $$Item in $objItem.' + $Prop + @CRLF
$Script = $Script + ' "*' + $Prop + ': " + $$Item ?' + @CRLF
$Script = $Script + ' Next' + @CRLF
Else
$Script = $Script + ' "' + $Prop + ': " + $$objItem.' + $Prop + ' ?' + @CRLF
Endif
Next
$Script = $Script + ' ?' + @CRLF
$Script = $Script + 'Next'
if "@scriptexe"="wkix32.exe"
$script = $script + @crlf + "? 'Press Any Key to close the window'" + @crlf + "get $"
endif
$TextBox.Text = $Script
$cmdRun.Enabled = 1
$cmdSave.Enabled = 1
$cmdRun.SetFocus
Else
$TextBox.Text = ""
$cmdRun.Enabled = 0
$cmdSave.Enabled = 0
Endif
$PForm.Hide
$Form.MousePointer = 0
$objWMIService = 0
EndFunction

Function RunScript()
$objFSO = CreateObject("Scripting.FileSystemObject")
$strTmpName = "%temp%\kixomatic_temp_script.kix"
$objScript = $objFSO.CreateTextFile($strTmpName)
$objScript.Write ($TextBox.Text)
$objScript.Close
$objShell = CreateObject("WScript.Shell")
if "@scriptexe"<>"wkix32.exe"
$strCmdLine = "kix32.exe"
else
$strCmdLine = "wkix32.exe"
endif
if @scriptdir<>@curdir and exist(@scriptdir + "\" + @scriptexe)
$strCmdLine = '"' + @scriptdir + $strCmdLine + '" "' + $strTmpName + '"'
else
$strCmdLine = '"' + $strCmdLine + ' "' + $strTmpName + '"'
endif
$nul = $objShell.Run($strCmdLine)
EndFunction

Function SaveScript()
$objFSO = CreateObject("Scripting.FileSystemObject")
$strTmpName = "temp_script.kix"
$objScript = $objFSO.CreateTextFile($strTmpName)
$objScript.Write ($TextBox.Text)
$objScript.Close
$dlgSave = $Form.FileSaveDialog("Save File",@SCRIPTDIR,$Class+".kix","KiX Files|*.kix|All Files|*.*|",2)
Copy $strTmpName $dlgSave
EndFunction

Function OpenScript()
$dlgOpen = $Form.FileOpenDialog("Open File",@SCRIPTDIR,,"KiX Files|*.kix|All Files|*.*|",4)
$objFSO = CreateObject("Scripting.FileSystemObject")
$objFile = $objFSO.OpenTextFile($dlgOpen)
$Script = $objFile.ReadAll()
$TextBox.Text = $Script
$objFile.Close
$Textbox.Show
$cmdRun.Enabled = 1
$cmdSave.Enabled = 1
EndFunction

Function QuitScript()
$objFSO = CreateObject("Scripting.FileSystemObject")
$objFSO.DeleteFile ("temp_script.kix")
$objFSO = 0
$nul=Setconsole("Show")
Quit()
EndFunction

Function WMIQuery($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")
$objEnumerator = $SystemSet.ExecQuery($strQuery)
For Each $objInstance in $objEnumerator
If @Error = 0 and $objInstance <> ""
$=execute("$$value = $$objInstance.$what")
$WMIQuery="$value"+"|"+"$WMIQuery"
EndIf
exit @error
Next
;$WMIQuery=left($WMIQuery,len($WMIQuery)-1)
exit @error
EndFunction



Edited by Lonkero (2005-07-06 07:23 PM)
_________________________
!

download KiXnet

Top
#128014 - 2005-07-06 03:21 PM Re: Kixomatic 2.1.2 - now with Wkix32
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I know, nobody besides me uses wkix32, but anyways, updated this.
_________________________
!

download KiXnet

Top
#128015 - 2005-07-06 06:31 PM Re: Kixomatic 2.1.2 - now with Wkix32
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Not true, I use WKIX32 but not as religiously as you do.
Top
#128016 - 2005-07-06 06:38 PM Re: Kixomatic 2.1.2 - now with Wkix32
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
What?? I/we use WKIX32 almost exclusively now.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#128017 - 2005-07-06 07:21 PM Re: Kixomatic 2.1.2 - now with Wkix32
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
good to hear.
anyways, I added support for UNC launched scripts. (not so often but possible)
if script is launched from UNC location, @scriptdir takes precedence over %path%
_________________________
!

download KiXnet

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 1013 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.054 seconds in which 0.026 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