Sign in to follow this  
Followers 0
strah

winmgmts object in AutoIt

5 posts in this topic

Hi!

Could anyone help me out with converting simple vbs script to au3 script.

Here is the vbs script content:

------------------------------------------------------

Const ALL_USERS = True

Set objService = GetObject("winmgmts:")

Set objSoftware = objService.Get("Win32_Product")

errReturn = objSoftware.Install("C:\SomeApplication.msi", , ALL_USERS)

MsgBox "Done"

--------------------------------------------------------

Here is my attempt to convert it to AutoIt:

--------------------------------------------------------

Const $ALL_USERS = 1

$objService = ObjGet("winmgmts:")

$objSoftware = $objService.Get("Win32_Product")

$errReturn = $objSoftware.Install("C:\SomeApplication.msi", , $ALL_USERS)

MsgBox(0,"","Done")

--------------------------------------------------------

This au3 script gives me an error.

I also used VBS2AutoIt_Converter to try to find my error, but VBS2AutoIt_Converter does pretty much what I did, so I could not detect the error.

If, however, I replace

$errReturn = $objSoftware.Install("C:\SomeApplication.msi", , $ALL_USERS)

with

$errReturn = $objSoftware.Install("C:\SomeApplication.msi")

it does work, but I would like to be able to keep ALL_USERS option. Anyone could help me find out what is wrong in line and how to correct it?

$errReturn = $objSoftware.Install("C:\SomeApplication.msi", , $ALL_USERS)

Thanks in advance,

Strah

Share this post


Link to post
Share on other sites

You may be able to get better replies in the AutoItX / COM / DLLs forum instead of the General Support forum.

Sorry, but I do not know about AutoItX that much :shocked:


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

seems complicated for using an msi

why not something simple like

Run(@SystemDir & "\msiexec.exe /i C:\SomeApplication.msi /qb")

Thanks gafrost. This works and is nice way of doing it. Can you do installation completely without any interface this way though? With winmgmts services you can do installation with no dialog boxes whatsoever, and its seems tremendously shorter as compared with any other approach. Thanks again,

Strah

Share this post


Link to post
Share on other sites

Thanks gafrost. This works and is nice way of doing it. Can you do installation completely without any interface this way though? With winmgmts services you can do installation with no dialog boxes whatsoever, and its seems tremendously shorter as compared with any other approach. Thanks again,

Strah

change /qb to /qn


SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

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