Jump to content

WMI ScriptOMatic tool for AutoIt


SvenP
 Share

Recommended Posts

I am using beta 3.1.1.98 - is this not the correct version?

P.S...nevermind, uninstalled auitoit then completly re-installed everything - now it works.

I also get that error if I do not run it with atleast the required beta version of AutoIt.

Using beta starts without error. :P

Edited by Spooky
Link to comment
Share on other sites

the Scriptomatic.au3 start correctly, but after waiting the list of wmi namespace and wmi class, its do not show me any choises, the microsoft Scriptomatic show a list of choise to select.

do i have to add some dll or other stuff?

By

Franco

Link to comment
Share on other sites

the Scriptomatic.au3 start correctly, but after waiting the list of wmi namespace and wmi class, its do not show me any choises, the microsoft Scriptomatic show a list of choise to select.

do i have to add some dll or other stuff?

By

Franco

No additional Dlls. It should work similar to the Microsoft version. Once WMI has loaded, then you should be able to use the combo's to select your choice of script. Working fine here with XP Pro and latest AutoIt Beta.
Link to comment
Share on other sites

  • Developers

win 2000 sp4, last scriptomatic, last autoscript beta.

if i put manualy the choise and select one of the output choise then i get the script, this is the only way to get the script.

many thanks for your answer.

By

Franco

Think its fixed in this version,....... :P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 1 month later...

Think its fixed in this version,....... ;)

Scriptomatic rocks (but you knew that)! :geek:

I'm having a little bit of trouble with it, though. I run Scriptomatic on my XP desktop, compile the script and post it on a CIFS share, from whence I run the compiled script on various servers (2000 SP4 and 2003 SP1). Execution appears to be sensitive to OS Version.

I use the WMISource, Win32_TapeDrive object to check on available tape drive identity, with Dialog selected. On the XP box (which has no tape drive) I get no output or errors at all, including no pop up dialogs, though I was expecting ""No WMI Objects Found for class: Win32_TapeDrive". On a Win2KAS server with a tape, same thing, I get nothing (no errors, no messages). On a Win2003 server, it works perfectly.

Using the Win32_BIOS object instead, the XP and 2003 boxes both work, but the 2000 box gets an error:

Line 0 (File "G:\MyFolder\WMI_BIOS.exe"):

$strBIOSVersion = $objItem.BIOSVersion(0)
$strBIOSVersion = $objItem.BIOSVersion(0)^ ERROR

Error: The requested action with this object has failed.

Are these WMI COM object calls typicaly so dependant on OS Version? It occurs to me that since Scriptomatic itself is running under XP when generating the script, that it is making XP or XP/2003 specific calls in its generated code.

I'd like to crank out some scripts that will give me WMI info on 2000 or 2003 servers without modification. Is this possible? Where should I be looking for the OS dependancy in the script?

:o

Update: I installed AutoIT 3.1.1, plus Beta 106, plus SciTE and update, plus Scriptomatic on one of the 2000 servers, and then ran Scriptomatic from there to generate a WMI - Win32_TapeDrive script. Same results.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 1 month later...

All works fine until i choose WMI Namespace diffrent then: root\CIMV2, then choosing anything on right makes scriptomatic to crash with following error:

C:\WMI.au3 (333) : ==> The requested action with this object has failed.:

$objClass = $objWMIService.Get($strSelectedClass)

$objClass = $objWMIService.Get($strSelectedClass)^ ERROR

@rambo3889 - try the fixed version from JDEB .. you can find it in his post. It works somewhat :)

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

  • 2 months later...

Source:

Opt('TrayMenuMode', 1)
TraySetToolTip ('Scriptomatic')
DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0)
#Include <GuiConstants.au3>
#Include <Array.au3>
#Include <GuiCombo.au3>
$maingui = GUICreate('WMI', 556, 700, -1, -1, $ws_sysmenu)
GUICtrlCreateLabel('WMI Namespace', 5, 5)
GUICtrlCreateLabel('WMI Classes', 480, 5)
$wmiok = GUICtrlCreateButton('RUN', 250, 25, 50, 21, $bs_flat)
$namespacecombo = GUICtrlCreateCombo('', 5, 25, 240, -1, $lbs_standard)
$wmi_classes = GUICtrlCreateCombo('', 305, 25, 240, -1, $lbs_standard)
GUICtrlSetState($namespacecombo, $gui_focus)
GUICtrlSetState($namespacecombo, $gui_disable)
GUICtrlSetState($wmi_classes, $gui_disable)
$dynamic = GUICtrlCreateCheckbox('Dynamic Classes', 268, 5, -1, 17)
GUICtrlSetState($dynamic, $gui_checked)
$edit = GUICtrlCreateEdit('', 5, 60, 540, 610, $es_autovscroll + $es_autohscroll)
GUISetState()
$tmp = StringSplit(WMI_Namespace(), @CRLF, 1)
For $temp = 1 To $tmp[0]
 GUICtrlSetData($namespacecombo, $tmp[$temp])
Next
GUICtrlSetState($namespacecombo, $gui_enable)
$setnamespace = ''
$disnamespace = 'Disable'
While 1
 $msg = GUIGetMsg()
 If $msg = $gui_event_close Then ExitLoop
 If $setnamespace <> GUICtrlRead($namespacecombo) And $disnamespace = 'Enable' Then
  $setnamespace = GUICtrlRead($namespacecombo)
  $disnamespace = 'Disable'
  GUICtrlSetState($wmi_classes, $gui_disable)
  _GUICtrlComboResetContent ($wmi_classes)
 EndIf
 If $msg = $namespacecombo And GUICtrlRead($namespacecombo) <> '' Then
  $setnamespace = GUICtrlRead($namespacecombo)
  _GUICtrlComboResetContent ($wmi_classes)
  WMI_Classes(GUICtrlRead($namespacecombo))
 EndIf
 GUICtrlSetTip($namespacecombo, GUICtrlRead($namespacecombo))
 GUICtrlSetTip($wmi_classes, GUICtrlRead($wmi_classes))
 If $msg = $wmi_classes Then Source(GUICtrlRead($namespacecombo), GUICtrlRead($wmi_classes))
 If $msg = $wmiok Then
  FileDelete(@TempDir & '\WMI.au3')
  $file = FileOpen(@TempDir & '\WMI.au3', 2)
  FileWrite($file, GUICtrlRead($edit))
  FileClose($file)
  If Not FileExists(@TempDir & '\AutoIt3.exe') Then FileInstall('AutoIt3.exe', @TempDir & '\AutoIt3.exe', 1)
  RunWait(@TempDir & '\AutoIt3.exe' & " " & @TempDir & '\WMI.au3')
 EndIf
WEnd
Func WMI_Namespace($namespace = 'root', $wmimain = True, $computer = 'localhost')
 $objwmiservice = ObjGet ('winmgmts:\\' & $computer & '\' & $namespace)
 $wmi_namespace = ''
 If Not @error Then
  $colnamespaces = $objWMIService.InstancesOf ('__NAMESPACE')
  For $objnamespace In $colnamespaces
   $wmi_namespace = $wmi_namespace & $namespace & '\' & $objnamespace.name & @CRLF
   $wmi_namespace = $wmi_namespace & WMI_Namespace($namespace & '\' & $objnamespace.name, False)
  Next
  If Not $wmimain Then Return $wmi_namespace
 EndIf
 If $wmimain Then
  $wmi_namespace = 'root' & @CRLF & StringTrimRight($wmi_namespace, 2)
 EndIf
 Return $wmi_namespace
EndFunc   ;==>WMI_Namespace
Func WMI_Classes($g_strcurrentnamespace)
 $strclassescombo = ''
 $objclassdictionary = ObjCreate ('Scripting.Dictionary')
 $objqualifierdictionary = ObjCreate ('Scripting.Dictionary')
 $objwmiservice = ObjGet ('winmgmts:\\localhost\' & $g_strcurrentnamespace)
 If Not @error Then
  For $objclass in $objWMIService.SubclassesOf ()
   For $objqualifier In $objClass.Qualifiers_ ()
    $objQualifierDictionary.Add (StringLower($objqualifier.name), '')
   Next
   Select
    Case GUICtrlRead($dynamic) = 1
     If $objQualifierDictionary.Exists ('dynamic') Then
      $objClassDictionary.Add ($objclass.path_.class, '')
     EndIf
    Case Else
     $objClassDictionary.Add ($objclass.path_.class, '')
   EndSelect
   $objqualifierdictionary.removeall
  Next
  $objqualifierdictionary = ''
  If $objclassdictionary.count Then
   $strclassescombo = ''
   For $strwmiclass in $objclassdictionary
    $strclassescombo = $strclassescombo & $strwmiclass & @CRLF
   Next
  EndIf
 EndIf
 If @error Or $objclassdictionary.count = 0 Then
  $strclassescombo = ''
 EndIf
 $classes = ''
 $objclassdictionary = ''
 If StringRight($strclassescombo, 2) = @CRLF Then $strclassescombo = StringTrimRight($strclassescombo, 2)
 $classes = StringSplit($strclassescombo, @CRLF, 1)
 If IsArray($classes) Then
  _ArraySort($classes, 0, 1)
  For $temp = 1 To $classes[0]
   GUICtrlSetData($wmi_classes, $classes[$temp])
  Next
  GUICtrlSetState($wmi_classes, $gui_enable)
  $disnamespace = 'Enable'
 EndIf
 Select
  Case $classes[0] - 0 = 0
   _GUICtrlComboSetMinVisible ($wmi_classes, 0)
  Case $classes[0] - 0 < 25 And $classes[0] - 0 > 0
   _GUICtrlComboSetMinVisible ($wmi_classes, $classes[0] - 0)
  Case Else
   _GUICtrlComboSetMinVisible ($wmi_classes, 25)
 EndSelect
EndFunc   ;==>WMI_Classes
Func Source($namespace_wmi, $classes_wmi)
 GUICtrlSetData($edit, '')
 $objwmiservice = ObjGet ("winmgmts:{impersonationLevel=impersonate}!\\localhost\" & $namespace_wmi)
 $objclass = $objWMIService.Get ($classes_wmi)
 If IsObj ($objclass) Then
  $source = ''
  $source &= "Opt('TrayMenuMode',1)" & @CRLF
  $source &= "TraySetToolTip ('" & $classes_wmi & "')" & @CRLF
  $source &= @CRLF
  $source &= "const $wbemFlagReturnImmediately = 0x10" & @CRLF
  $source &= "const $wbemFlagForwardOnly = 0x20" & @CRLF
  $source &= "$colItems = ''" & @CRLF
  $source &= "$output=''" & @CRLF
  $source &= "$strComputer = 'localhost'" & @CRLF
  $source &= "$objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\" & $namespace_wmi & "')" & @CRLF
  $source &= "$colItems = $objWMIService.ExecQuery('SELECT * FROM " & $classes_wmi & "', 'WQL', _" & @CRLF & Chr(9) & Chr(9) & "$wbemFlagReturnImmediately + $wbemFlagForwardOnly)" & @CRLF
  $source &= @CRLF
  $source &= "If IsObj($colItems) Then" & @CRLF
  $source &= "   For $objItem In $colItems" & @CRLF
  For $objproperty in $objClass.Properties_ ()
   Select
    Case $objproperty.isarray = True
     $source &= "      $output&='" & $objproperty.name & ":' & $objItem." & $objproperty.name & "(0) & @CRLF" & @CRLF
    Case $objproperty.cimtype = 11
     $source &= "      $output&='" & $objproperty.name & ":' & Not(Not($objItem." & $objproperty.name & ")) & @CRLF" & @CRLF
    Case $objproperty.cimtype = 8
     $source &= "      $output&='" & $objproperty.name & ":' & String($objItem." & $objproperty.name & ") & @CRLF" & @CRLF
    Case $objproperty.cimtype = 101
     $source &= "      $output&='" & $objproperty.name & ":' & WMIDateStringToDate($objItem." & $objproperty.name & ") & @CRLF" & @CRLF
    Case $objproperty.cimtype = 13
    Case Else
     $source &= "      $output&='" & $objproperty.name & ":' & $objItem." & $objproperty.name & " & @CRLF" & @CRLF
   EndSelect
  Next
 EndIf
 $source &= "      If Msgbox(1,'WMI Output',$Output) = 2 Then ExitLoop" & @CRLF
 $source &= "      $output=''" & @CRLF
 $source &= "   Next" & @CRLF
 $source &= "EndIf" & @CRLF
 $source &= @CRLF
 $source &= "Func WMIDateStringToDate($dtmDate)" & @CRLF
 $source &= "  Return (StringMid($dtmDate, 5, 2) & '/' & _" & @CRLF
 $source &= "    StringMid($dtmDate, 7, 2) & '/' & StringLeft($dtmDate, 4) _" & @CRLF
 $source &= "    & ' ' & StringMid($dtmDate, 9, 2) & ':' & StringMid($dtmDate, 11, 2) & ':' & StringMid($dtmDate,13, 2))" & @CRLF
 $source &= "EndFunc" & @CRLF
 GUICtrlSetData($edit, $source)
EndFunc   ;==>Source

oÝ÷ Ûú®¢×¬º²×!jx"ë¢f®¶­s` bæ÷BfÆTW7G2FV×F"fײb33²b3#´WFôC2æWRb33²FVâfÆTç7FÆÂb33´WFôC2æWRb33²ÂFV×F"fײb33²b3#´WFôC2æWRb33²Â 'VåvBFV×F"fײb33²b3#´WFôC2æWRb33²fײgV÷C²gV÷C²fײFV×F"fײb33²b3#µtÔæS2b33² oÝ÷ ÚÚºÚ"µÍBT[ØZ]
    ÌÎNÉ][ÝÉÌÎNÈ    [È]]Ò]^[È ÌÎNÉ][ÝÉÌÎNÈ    [È ÌÎNÈÐ]]Ò]Ñ^]TØÜ  ÌÎNÈ [È ][ÝÈ  ][ÝÈ  [È[    [È ÌÎNÉÌLÕÓRK]LÉÌÎNÊB

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • 3 weeks later...

Excellent work!

I used the script from the first page and had to edit several lines before it would work. I'm using beta 3.1.1.127.

Changed lines 346 to 348 from this:

$strScriptCode = $strScriptCode & "$Output = $Output & '<html><head><title>Scriptomatic HTML Output</title></head><body> _
  <style>table {font-size: 10pt; font-family: arial;} th {background-color: buttonface; font-decoration: bold;} _
  </style><table BORDER=" & Chr(34) & "1" & Chr(34) & "><tr><th>Property</th><th>Value</th></tr>'" & @CRLF

to this:

$strScriptCode  = $strScriptCode & "$Output = $Output & '<html><head><title>Scriptomatic HTML Output</title></head><body>" _
  & "<style>table {font-size: 10pt; font-family: arial;} th {background-color: buttonface; font-decoration: bold;}" _
  & "</style><table BORDER=" & Chr(34) & "1" & Chr(34) & "><tr><th>Property</th><th>Value</th></tr>'" & @CRLF

And changed lines 507-509 from this:

$strWMISourceName = InputBox("Set WMI Repository Source",_
  "Please enter the computer whose WMI repository you want to read from: ",_
  $g_strWMISource)

to this (added space before line continuation _):

$strWMISourceName = InputBox("Set WMI Repository Source", _
  "Please enter the computer whose WMI repository you want to read from: ", _
  $g_strWMISource)

Then it worked.

BlueBearrOddly enough, this is what I do for fun.
Link to comment
Share on other sites

@psandu.ro

I have tested the tenewed code.

But I have my doubts about the integrity of the code.

I have run the original VBscript version selecting Root/WMI "MSStorageDriver_ATAPISmartData"

And compared this against the new code.

This not exacty the same !!

This is the original output :

Active: -1

Checksum: 244

ErrorLogCapability: 1

ExtendedPollTimeInMinutes: 31

InstanceName: IDE\DiskST94019A________________________________3.09____\5&13b9a31c&0&0.0.0_0

Length: 512

OfflineCollectCapability: 91

OfflineCollectionStatus: 130

Reserved: 0,0,0,0,0,0,0,0,0,0,0,0

SelfTestStatus: 0

ShortPollTimeInMinutes: 1

SmartCapability: 3

TotalTime: 426

VendorSpecific: 10,0,1,15,0,67,60,118,211,207,3,0,0,0,3,3,0,99,99,0,0,0,0,0,0,0,4,50,0,100,100,148,1,0,0,0,0,0,5,51,

0,100,100,0,0,0,0,0,0,0,7,15,0,78,60,76,129,199,3,0,0,0,9,50,0,93,93,205,24,0,0,0,0,0,10,19,0,100,10

0,0,0,0,0,0,0,0,12,50,0,100,100,21,2,0,0,0,0,0,192,50,0,100,100,141,0,0,0,0,0,0,193,50,0,1,1,12,69,3

,0,0,0,0,194,34,0,41,55,41,0,0,0,0,0,0,195,26,0,67,60,118,211,207,3,0,0,0,197,18,0,100,100,0,0,0,0,0

,0,0,198,16,0,100,100,0,0,0,0,0,0,0,199,62,0,200,200,0,0,0,0,0,0,0,200,0,0,100,253,0,0,0,0,0,0,0,202

,50,0,100,253,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

VendorSpecific2: 0

VendorSpecific3: 0

VendorSpecific4: 223,199,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,236,156,136,136,8,1,0,0,0,0,0,0,

1,0,0,0,0,0,0,0,0,0,0,0,0,0,124,1,130,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

This is the output of the new code :

Active: True

Checksum: 244

ErrorLogCapability: 1

ExtendedPollTimeInMinutes: 31

InstanceName: IDE\DiskST94019A________________________________3.09____\5&13b9a31c&0&0.0.0_0

Length: 512

OfflineCollectCapability: 91

OfflineCollectionStatus: 130

Reserved: 0

SelfTestStatus: 0

ShortPollTimeInMinutes: 1

SmartCapability: 3

TotalTime: 426

VendorSpecific: 10

VendorSpecific2: 0

VendorSpecific3: 0

VendorSpecific4: 223

Also If you compare the original source code of SvenP which was 21 Kb large, the new code is only 7 Kb large ?

Isn' t something that was skipped.

I think it would be better to get the original code repaired.

Link to comment
Share on other sites

  • 3 weeks later...

thanks jon.

This is the AutoIt's version of Microsoft Scriptomatic tool. Which took me some hours to rewrite (yes, yes, I'm not such a fast script writer).

:D me too.

btw nice job

Edited by WTS
Link to comment
Share on other sites

Added a fixed version into the first post.

it's crashing on me:

1- Set the WMI Name space to: "root\WMI"

2- when selecting any WMI Class I get this error:

>"C:\Program Files\AutoIt3\SciTE\CompileAU3\CompileAU3.exe" /run /beta /ErrorStdOut /in "C:\Documents and Settings\****\Desktop\scriptomatic.au3" /autoit3dir "C:\Program Files\AutoIt3\beta" /UserParams   
>Running AU3Check (1.54.1.0)  params:  from:C:\Program Files\AutoIt3\beta
+>AU3Check ended.rc:0
>Running:(3.1.1.129):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Documents and Settings\*****\Desktop\scriptomatic.au3"   
C:\Documents and Settings\****\Desktop\scriptomatic.au3 (333) : ==> The requested action with this object has failed.: 
$objClass = $objWMIService.Get($strSelectedClass) 
$objClass = $objWMIService.Get($strSelectedClass)^ ERROR
+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 69.750
Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...