Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBScript to help automate software installs

Posted on 2009-05-06
3
Medium Priority
?
861 Views
Last Modified: 2012-06-03
I'm looking to automate some software installs.  For example install .NET2.0SP1, C++ Package, SOme ActiveX Controls from one VBScript.  How Can this be done?   Thanks...
0
Comment
Question by:DougAZ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 20

Expert Comment

by:ltlbearand3
ID: 24321839
Sure this can be done.  Your script would need access to the install files for each piece of software that you want to install.  Depending on how much you want to display while it it being run, some exe files will have switches to make silent or on the other end you could make VBscript give updates in an IE window.

Below is the basic code to have vb script run the install file.  By using strReturn, it will wait for each install to finish

Dim strReturn, objShell
Set objShell = CreateObject("WScript.Shell")
strReturn = objShell.Run ("C:\pathtofile\installfile.exe", 1, true)
strReturn = objShell.Run ("C:\pathtofile\installfile2.exe", 1, true)

Open in new window

0
 

Author Comment

by:DougAZ
ID: 24321879
Couple of Questions:
  - If MSI or EXE have command line switches would I put them in the " "?
  - What are the other values (....,1, true)?
  - If I could expand this question...  How can you set some IE Settings like  Disable Script Debugging (Internet Explorer) and Disable Script Bebugging (Other)

Thanks..
0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 1000 total points
ID: 24322176
DougAZ,

Here you go:
1.  Yes put switches inbetween the " ".  When I have multiple commands I usually set up a string array for the exe files and then loop through the arrary calling the objShell.Run process
2.  1 is for show window, true is wait for return value.   See http://msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx for more information
3.  I don't know that I follow this question.  Are you wanting to set IE Security settings via a script?  Some IE settings like Proxy can be set via the registry, but I have never had much good luck with that.  You have to set this by adjusting the registry  
HKCU\Software\Microsoft\InternetExplorer\Main

Below is a sample registry script I found awhile ago and keep for registry update reference.

-Bear

Option Explicit
 
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005
 
Dim strComputer
Dim objRegistry
Dim strKeyPath
Dim strValueName
Dim strValue
Dim arrValues
Dim intValue
 
strComputer = "."
 
Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
 
'Create Key
strKeyPath = "Registry Test"
objRegistry.CreateKey HKEY_CURRENT_USER,strKeyPath
 
'Set String value
strKeyPath = "Registry Test"
strValueName = "String Test"
strValue = "123"
objRegistry.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
 
'Get String value
strKeyPath = "Registry Test"
strValueName = "String Test"
objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
Wscript.Echo strValueName & " = " & strValue
 
'Delete String value
strKeyPath = "Registry Test"
strValueName = "String Test"
objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName
 
'Set Binary value
strKeyPath = "Registry Test"
strValueName = "Binary Test"
arrValues = Array(1,2,3,4,5,6,7,8,9,10)
objRegistry.SetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
 
'Get Binary value
strKeyPath = "Registry Test"
strValueName = "Binary Test"
objRegistry.GetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
For Each strValue In arrValues
Wscript.Echo strValueName & " = " & strValue
Next
 
'Delete Binary value
strKeyPath = "Registry Test"
strValueName = "Binary Test"
objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName
 
'Set DWORD value
strKeyPath = "Registry Test"
strValueName = "DWORD Test"
intValue = 123
objRegistry.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,intValue
 
'Get DWORD value
strKeyPath = "Registry Test"
strValueName = "DWORD Test"
objRegistry.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,intValue
Wscript.Echo strValueName & " = " & intValue
 
'Delete DWORD value
strKeyPath = "Registry Test"
strValueName = "DWORD Test"
objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName
 
'Set Multi-String value
strKeyPath = "Registry Test"
strValueName = "Multi-String Test"
arrValues = Array("Test1","Test2","Test3")
objRegistry.SetMultiStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
 
'Get Multi-String value
strKeyPath = "Registry Test"
strValueName = "Multi-String Test"
objRegistry.GetMultiStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrValues
For Each strValue In arrValues
Wscript.Echo strValueName & " = " & strValue
Next
 
'Delete Multi-String value
strKeyPath = "Registry Test"
strValueName = "Multi-String Test"
objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName
 
'Set Expandable String value
strKeyPath = "Registry Test"
strValueName = "Expandable String Test"
strValue = "123"
objRegistry.SetExpandedStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
'Get Expandable String value
strKeyPath = "Registry Test"
strValueName = "Expandable String Test"
objRegistry.GetExpandedStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
Wscript.Echo strValueName & " = " & strValue
 
'Delete Expandable String value
strKeyPath = "Registry Test"
strValueName = "Expandable String Test"
objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValueName
 
'Delete Key
strKeyPath = "Registry Test"
objRegistry.DeleteKey HKEY_CURRENT_USER,strKeyPath
 
Set objRegistry = Nothing
 
'Loop Through SubKey
strKeyPath = "SYSTEM\CurrentControlSet\Services"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
 
For Each subkey In arrSubKeys
    Wscript.Echo subkey
Next
	

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question