Hi,

I am trying to install programs with msi's using VB
Script. I have found code that says,
-------
Const ALL_USERS = True
Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install
("c:\scripts\database.msi", , ALL_USERS)
-----
the code I have been trying says
-----
Const ALL_USERS = True
Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install("\\server1
\DotNet$\netfx.msi /Q", , ALL_USERS)
----
I get do response from the script. The paths to the msi
location are correct.

Any help would be appreciated.

Wayne

Re: Installing programs with VbScript by Torgeir

Torgeir
Fri Dec 05 05:19:03 CST 2003

Wayne wrote:

> Hi,
>
> I am trying to install programs with msi's using VB
> Script. I have found code that says,
> -------
> Const ALL_USERS = True
> Set objService = GetObject("winmgmts:")
> Set objSoftware = objService.Get("Win32_Product")
> errReturn = objSoftware.Install
> ("c:\scripts\database.msi", , ALL_USERS)
> -----
> the code I have been trying says
> -----
> Const ALL_USERS = True
> Set objService = GetObject("winmgmts:")
> Set objSoftware = objService.Get("Win32_Product")
> errReturn = objSoftware.Install("\\server1
> \DotNet$\netfx.msi /Q", , ALL_USERS)
> ----
> I get do response from the script. The paths to the msi
> location are correct.

Hi

Where does this script run, in a computer startup script, or user logon script,
or do you just run it interactively?

If you put netfx.msi on the local hard disk and change your script to point to
the local copy, does your script run then?


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Re: Installing programs with VbScript by Wayne

Wayne
Fri Dec 05 06:59:18 CST 2003

Hi,

Thanks for the reply. The script is in the GUIRunOnce
section of the unattended.sif

I am using an RIS server. The script resides in $oem$\$1
\Scripts folder and is copied to the local machine during
installation. I can only assume it is being executed on
the local machine.

Thus the reference to the share for the msi.

I just tested it by placing the msi on the local machine,
changing the script to:

Const ALL_USERS = True
Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install
("c:\DotNet\netfx.msi /Q", , ALL_USERS)

I got the following error

Line 3
Char 1
Error Not Found
Code 80041002
Source: SWbemServicesEx

However I can assure that the file is in the location as
specified.

thanks

Wayne

>-----Original Message-----
>Wayne wrote:
>
>> Hi,
>>
>> I am trying to install programs with msi's using VB
>> Script. I have found code that says,
>> -------
>> Const ALL_USERS = True
>> Set objService = GetObject("winmgmts:")
>> Set objSoftware = objService.Get("Win32_Product")
>> errReturn = objSoftware.Install
>> ("c:\scripts\database.msi", , ALL_USERS)
>> -----
>> the code I have been trying says
>> -----
>> Const ALL_USERS = True
>> Set objService = GetObject("winmgmts:")
>> Set objSoftware = objService.Get("Win32_Product")
>> errReturn = objSoftware.Install("\\server1
>> \DotNet$\netfx.msi /Q", , ALL_USERS)
>> ----
>> I get do response from the script. The paths to the msi
>> location are correct.
>
>Hi
>
>Where does this script run, in a computer startup script,
or user logon script,
>or do you just run it interactively?
>
>If you put netfx.msi on the local hard disk and change
your script to point to
>the local copy, does your script run then?
>
>
>--
>torgeir
>Microsoft MVP Scripting and WMI, Porsgrunn Norway
>Administration scripting examples and an ONLINE version
of the 1328 page
>Scripting Guide:
http://www.microsoft.com/technet/scriptcenter
>
>
>.
>

Re: Installing programs with VbScript by Torgeir

Torgeir
Fri Dec 05 07:56:30 CST 2003

Wayne wrote:

> (snip)
> the code I have been trying says
> -----
> Const ALL_USERS = True
> Set objService = GetObject("winmgmts:")
> Set objSoftware = objService.Get("Win32_Product")
> errReturn = objSoftware.Install("\\server1
> \DotNet$\netfx.msi /Q", , ALL_USERS)
> ----
> I get do response from the script. The paths to the msi
> location are correct.

Hi

After a second look and some testing:

You can't add /Q or any other command line switch to the first parameter
(PackageLocation), but WMI will default to run it as /Q anyway so you don't
need it.

The second parameter (Options) is for command line options for the installation
but only in the form of property=setting.

The third parameter (AllUsers) must be present, but the documentation says
that it is ignored (true is the recommended value)!

The documentation for this method can be found here:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/install_method_in_class_win32_product.asp

This should work (with an all users setting in the second parameter Options as
well):

Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install _
("\\server1\DotNet$\netfx.msi", "ALLUSERS=2" , True)

If errReturn = 0 Then
WScript.Echo "Installation success!"
Else
WScript.Echo "Installation failure!"
End If



If the installation reboots by itself, this might stop it from doing that:

errReturn = objSoftware.Install _
("\\server1\DotNet$\netfx.msi", "ALLUSERS=2 REBOOT=ReallySuppress" , True)

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter