Sign in to follow this  
Followers 0
dbenoit

What if the windows system in installed on H: ?

9 posts in this topic

Hello,

I tryed to make my exisiting scrypts running when the OS is not install on C: (for exemple H:\).

Unfortuantly, each time I am using a function call to something involve Windows API, it fail on error.

For exemple

_CreateService("", $servicename, "My Service", @WindowsDir & "\srvany.exe", "LocalSystem", "", 0x110)

_ComputerGetProcessors(ByRef $aProcessorInfo)

_ComputerGetGroups

Do not work any more and generate a "not object" error.

I suppose this is becaue of the global variable but I do not know what and wher I have something to change.

Thnks for your help.

Dominique

Share this post


Link to post
Share on other sites



we cant help u unless u post your code

Share this post


Link to post
Share on other sites

we cant help u unless u post your code

Here is a quick exemple :

Global $ERR_NO_INFO = "Array contains no information", _

$ERR_NOT_OBJ = "$colItems isnt an object"

Dim $Processors, $pos[2]

If Not (IsDeclared("$cI_CompName")) Then Global $cI_CompName = @ComputerName

Global $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20

msgbox(0,"My CPU is : ", _ComputerGetProcessors($Processors))

Exit

Func _ComputerGetProcessors(ByRef $aProcessorInfo)

Local $colItems, $objWMIService, $objItem

Dim $aProcessorInfo[1][42], $i = 1

$objWMIService = ObjGet("winmgmts:\\" & $cI_CompName & "\root\CIMV2")

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) Then

For $objItem In $colItems

ReDim $aProcessorInfo[uBound($aProcessorInfo) + 1][42]

$aProcessorInfo[$i][0] = StringStripWS($objItem.Name, 1)

$aProcessorInfo[$i][37] = $objItem.SystemName

$i += 1

Next

$aProcessorInfo[0][0] = UBound($aProcessorInfo) - 1

If $aProcessorInfo[0][0] < 1 Then

SetError(1, 1, 0)

EndIf

Else

SetError(1, 2, 0)

EndIf

Return $aProcessorInfo[1][0]

EndFunc ;==>_ComputerGetProcessors

This code works fine when XP is installed on C:

but

When XP is installed on H:, then after 30 seconds wait, it ends with the folowing message

>"H:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "H:\Documents and Settings\planet\Desktop\New AutoIt v3 Script.au3"

H:\Documents and Settings\planet\Desktop\New AutoIt v3 Script.au3 (22) : ==> Variable must be of type "Object".:

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

$colItems = $objWMIService^ ERROR

>Exit code: 1 Time: 30.314

I hope this will be enough for you to help me.

Kind regards

Dominique

Share this post


Link to post
Share on other sites

Your code works fine for me (Windows XP 64 bit, installed on drive E:).

Could you please tell me what release of AutoIt you are using ? Is it a beta one ?

Many thanks for having done the test. I am very upset by this issue (on my side) because I have something like 25.000 lines of Autoit code so far and I would like to see them working fine even in such situation.

Kind regards

Dominique

Share this post


Link to post
Share on other sites

Hello,

I downloaded the same release, but I get the same error.

My trouble is due to $objWMIService.ExecQuery

I don't know why. I am not easy at all with this kind of call. Do you have any idea of where I have to look at ?

Kind regards

Dominique

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Hello,

I downloaded the same release, but I get the same error.

My trouble is due to $objWMIService.ExecQuery

I don't know why. I am not easy at all with this kind of call. Do you have any idea of where I have to look at ?

Kind regards

Dominique

@dbenoit

The Windows Management Instrumentation service on that machine is disabled

there are a few service UDFS on the forum you could use to check WMI service status before running any WMI code

Cheers

Edit: missing end of quote bracket

Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

@dbenoit

The Windows Management Instrumentation service on that machine is disabled

there are a few service UDFS on the forum you could use to check WMI service status before running any WMI code

Cheers

Edit: missing end of quote bracket

Thank, You are right. The problem is due to WMI service which is not started on my test PC.

Kind regards

Dominique

Share this post


Link to post
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
Sign in to follow this  
Followers 0