[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.8

Need help with this script which installs a msi file in all users in the group

Asked by bsharath in Scripting Languages, Programming Languages, Windows Installer

Hi,

I am using this...
cscript.exe /nologo "\\indiasophos\Ps\Msi.vbs" title:"Microsoft Office OneNote 2003 Setup" path:"\\indiasophos\Ps\ONOTE11.MSI" group:".net"

Script starts here...

'http://www.vbshf.com/vbshf/forum
'
'Author:
'Rob Dunn  
'
'Email Address:
'uphold2001@hotmail.com
'
'Script Name:
'installmsiapp.vbs
'
'Script Version:
'1.0
'
'Description:
'This script will help you install a particular application based upon user
' membership in a particular domain group.  Installmsiapp will check the
' computer's installed (MSI) applications, see if it can find the requested
' software title, then install the app if it is missing, and if the logged
' in user is a member of the requested domain group (no nested groups currently)
'
'Note that this is for MSI-packaged applications ONLY.
'
'The script will take three inputs as command-line parameters:
'
'title: the application title of the MSI (i.e. "Microsoft .NET Framework 1.1")
'path: the path of the installation MSI (i.e. "\\fileserver\share\netfx.msi)
'group: the name of the domain group (i.e. "Install - .NET")
'
'Note: the group must be a domain group of the currently logged in user domain.
' Also, the name must match EXACTLY (case-insensitive).  If the user is not
' a member of the specified group, the script will exit without checking to see
' if the application is installed or not.  This allows for faster processing.
'
'If the requested application is not installed, a popup dialog will
' appear, telling the user that the application needs to be installed and
' to please wait (this will disappear after 10 seconds (default)).
'
'When the msi installs, it will use the /passive msiexec.exe command-line
' switch, which only shows a progress bar, but no other intervention is
' necessary.
'
'This script is particularly useful for deploying applications via the logon
' script, but you don't want to go the route of deploying via GPO (or if
' perhaps the GPO isn't working properly with a third-party MSI).
'
'An example of this being called from a batch file login script:
'
'cscript.exe /nologo "\\indiasophos\Ps\Msi.vbs" title:"Microsoft Office OneNote 2003 Setup" path:"\\indiasophos\Ps\ONOTE11.MSI" group:".net"
'
'So, in this case, you would create a user group on the domain level called
' 'Install -  .Net 1.1', add users to it, then assign the batch file containing
' the above code to those users...or, you can deploy a GPO with this as a
' logon script, then only give 'Install - .Net 1.1' permissions to apply it
' through the security filtering tab...then assign the GPO to the domain.

'Declare a couple of constants for our WMI connection string (courtesy of
' the Microsoft Scriptomatic 2.0 tool).
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

On Error goto 0

'Declare objects
Set objArgs = WScript.Arguments

'Declare variables
dim bInstalled

'Set to 'false' since we are assuming NOT installed, we will check later...
bInstalled = false

'Show variables as they are being passed, status, etc. -
' 0 = No debug, perform installation
' 1 = Debug, show variables, no installation (don't run MSI at end of script)
iDebug = 0

'Get command-line arguments
If objargs.count < 1 Then
  'If no command line parameters are passed, exit the script.
  wscript.quit
Else

 'Go through all the command-line options and find out what was passed.
 For I = 0 to objArgs.Count - 1
   'Find the title of the application we are looking for.
   If InStr(1,LCase(objargs(I)),"title:") Then
         arrTitle = split(objargs(I),"title:")
         strTitle = arrTitle(1)
         if idebug = 1 then wscript.echo "Title: " & strTitle
       ElseIf InStr(1,LCase(objargs(I)),"path:") Then
    'Find the path of the application down to the .msi extension for the title
    ' we were shown above.
         arrPath = split(lcase(objargs(I)),"path:")
         strPath = arrPath(1)
         if idebug = 1 then wscript.echo "Path: " & strPath
   ElseIf InStr(1,LCase(objargs(I)),"group:") Then
    'What domain group does this user (who is running the script) need to belong
    ' to in order for the .msi to run?
         arrGroup = split(objargs(I),"group:")
         strGroup = arrGroup(1)
         if idebug = 1 then wscript.echo "Group: " & strGroup
   Else
   
   End If
 
 Next
 
End If

'Find out if the currently logged on user is a member of the group we specified
' in strGroup above.  If the user is not a member, then quit the script.
If isMember(strGroup) = false then wscript.quit

'Show text - - if run with cscript.exe, this will show up in the console window
' for the logon script.  If not, it will show up in a pop-up window.
wscript.echo "Verifying install status for " & strTitle

If idebug = 1 then wscript.echo "Is a member of " & strGroup & ": " & IsMember(strGroup)

'Find out if the application we specified is installed - - - i.e. call the
' function that checks the status.
Call CheckInstalledStatus

Function CheckInstalledStatus

'When strComputer = ".", then that means tell the script to check the computer
' which is running the script.

strComputer = "."

   'Create connection via WMI to computer.
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
 
   'Perform a WQL (Windows Query Language) query through the WMI connection
   ' above, and output the results to a collection called 'colItems'.
   Set colItems = objWMIService.ExecQuery("SELECT Caption FROM Win32_Product where caption='" & strTitle & "'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
   
   'Move through each item in the collection.
   For Each objItem In colItems
   
    'If one of the captions has the text that we specified for the title (i.e.
    ' strTitle, then we know the application is installed.
    If instr(objItem.Caption,strTitle) then
      WScript.Echo objItem.Caption & " is installed.  Continuing script..."
      wscript.echo " "

      'Set this variable to 'true' so we can reference it later.
      bInstalled = true
    End If
   Next

   'If the application is not installed, then install the application...
   If bInstalled = false then
   
      Set WshShell = WScript.CreateObject("WScript.Shell")
     
      'Give the user a warning telling them what is going on.  This will
      ' disappear after 10 seconds.
      WshShell.Popup "Now installing '" & strTitle & "', please stand by, this may take a few minutes..." & vbcrlf & vbcrlf & "This message will disappear in 10 seconds", 10, "Software installation in progress", 64
     
      'Set the command line we are going to run, using the path we specified
      ' in strPath above.  Use the /passive switch so that the user will only
      ' see the progress bar during installation.
      sCmd = "msiexec.exe /i " & chr(34) & strPath & chr(34) & " /passive"
     
      if idebug = 1 then wscript.echo "Command: " & sCmd
      if idebug <> 1 then wshshell.run sCmd,1,true
   Else
      'If the application is installed, then show a quick blurb in the console
      ' window.
      if idebug = 1 then wscript.echo strTitle & " is already installed on this computer."
   End If
   
End Function

'******************************************************************************
'Function IsMember(groupName)
'
'Input: Title of group name you wish to query against.  This will check the
' domain and logged on user ID to find out whether or not it is a member of the
' specified group in 'strGroup' - the title must match the group name exactly.
'******************************************************************************
Private Function IsMember(groupName)
  'Instantiate the network object
  Set netObj = CreateObject("WScript.Network")
 
  'Set variable sDomain to the logged on user's domain.
  sDomain = netObj.UserDomain

  'Set variable sUser to the logged on user's ID.
  sUser = netObj.UserName
 
  'Set is member to false, as if there any problems we want to err on the side
  ' of caution (don't install if we don't know he/she is a member)
  flgIsMember = false
 
  'Attach to the user object in the domain using the WinNT provider.
  Set userObj = GetObject("WinNT://" & sDomain & "/" & sUser & ",user")
 
  'Move through each group that this user is a member of.
  For Each grp In userObj.Groups
   
    'If the name of one of the user's groups match the one we specified then
    ' the user is a member...i.e. flgIsMember = true.
    If grp.Name = groupName Then
    flgIsMember = true
   
    'Don't keep searching, so exit the 'for' loop.
    Exit For
  End If
  Next

'IsMember will equal 'true'/'false', depending on what the code above found.
IsMember = flgIsMember

'Set declared objects to nothing to free up memory.
Set userObj = nothing
Set netObj = nothing

End Function
'*******************************************************************************
[+][-]10/17/07 02:20 AM, ID: 20091802Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/21/07 11:38 PM, ID: 20121151Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/21/07 11:52 PM, ID: 20121197Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/22/07 12:14 AM, ID: 20121285Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/22/07 12:20 AM, ID: 20121311Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/07 07:31 PM, ID: 20135975Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/07 07:32 PM, ID: 20135980Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/07 07:47 PM, ID: 20136025Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/07 07:47 PM, ID: 20136026Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/07 07:56 PM, ID: 20136058Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/07 08:10 PM, ID: 20136104Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/07 10:54 PM, ID: 20136555Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/07 10:59 PM, ID: 20136570Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/07 11:15 PM, ID: 20136605Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/07 11:25 PM, ID: 20136630Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/07 11:39 PM, ID: 20136689Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/07 11:47 PM, ID: 20136724Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/07 11:52 PM, ID: 20136749Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/24/07 12:24 AM, ID: 20136865Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/07 12:00 AM, ID: 20145585Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/25/07 12:03 AM, ID: 20145596Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/07 04:38 AM, ID: 20146617Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/07 04:04 PM, ID: 20152198Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/25/07 07:26 PM, ID: 20152830Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/07 07:34 PM, ID: 20152855Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/07 09:26 PM, ID: 20153145Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Scripting Languages, Programming Languages, Windows Installer
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 1
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81 / EE_QW_1_20070628