[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Windows Scripting to remove and install applications

Does anyone have a script or two that I can look at that will add or remove an application from the computer? Can this be done with WSH? or do I need to go another route?


Thanks,
0
ampapa
Asked:
ampapa
  • 6
  • 4
  • 4
  • +1
3 Solutions
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Can't speak on WSH, but there's two other ways to do this:

1) if the product supports silent installs - look at the product documentation
2) through active directory Group Policies Objects by assigning/publishing software to users and/or computers.
0
 
Debsyl99Commented:
Hi
I came across this a while ago: It will uninstall software, provided there's an associated msi package. The entire script first unistall softare where SoftwareName is the title of the software to be uninstalled. It produces a list in csv format of the software on the pc that it can uninstall, you'll need to create a scripts folder to take the csv. Will post the link if I can find it. Put it in a .vbs file - hope it's relevant - It worked for what I needed it for, but I've put it to very limited use,

Deb :))




dim software:software = "SoftwareName"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery("SELECT * FROM Win32_Product WHERE Name = '" & software & "'")
For Each objSoftware in colSoftware
    objSoftware.Uninstall()
Next

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\scripts\software.csv", True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Product")
objTextFile.WriteLine "Caption" & "," & _
    "Description" & "," & "Identifying Number" & "," & _
    "Install Date" & "," & "Install Location" & "," & _
    "Install State" & "," & "Name" & "," & _
    "Package Cache" & "," & "SKU Number" & "," & "Vendor" & "," _
        & "Version"
For Each objSoftware in colSoftware
    objTextFile.WriteLine objSoftware.Caption & "," & _
    objSoftware.Description & "," & _
    objSoftware.IdentifyingNumber & "," & _
    objSoftware.InstallLocation & "," & _
    objSoftware.InstallState & "," & _
    objSoftware.Name & "," & _
    objSoftware.PackageCache & "," & _
    objSoftware.SKUNumber & "," & _
    objSoftware.Vendor & "," & _
    objSoftware.Version
Next
objTextFile.Close
msgbox "Fin"
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
jdeclueCommented:
You may not need a script at all.

In windows XP, from a Command Prompt type "msiexec /?", this will give you all of the command line options for installing an application using msiexec.exe from a command propmt.

In WIndows 2000 and/or XP, go to help and search for MSIEXEC, review the command line options and instructions on how to use it.

The program MSIEXEC, is the Microsoft Installer, it is used by almost every software install. This program can use command line options to install almost any application, any way you want.

J
0
 
ampapaAuthor Commented:
Debsyl99,

Thanks for the script but my Application is not showing up as an item so I assume that it is unable to assist in the removal?

This application doesn't have an .MSI file so I think MSIEXEC is also out of the question.

0
 
jdeclueCommented:
In order for the application to show up in the add/remove programs, it must use the msiexec mechanism. If the program uses a different type of installation packaging then most "typical" scenarios will not work. Do you know how the application is packaged?

J
0
 
ampapaAuthor Commented:
It does show up in the add remove programs.

I tried from a Command Prompt typing "msiexec /?" and I get an error "incorrect command line parameters"?

Is VBScript an option? I'm guessing that any of the scripting routines might help?
0
 
jdeclueCommented:
Then you are on Windows 2000, correct? The 2000 version does not have the /? switch. Goto Start, Help, select "Search", type in MSIEXEC. The instructions and command line parameters are in the Windows 2000 Help Files. If the program does not have an MSI, take a look here, http://www.installsite.org/pages/en/msi/authoring.htm ... you can probably create one.

With that said, this is probably the real solution. Below are the instructions to configure a ZAP installation, for Group Policy installs. These can be published to the users through Active Directory.

How do I publish non-MSI programs?

Non-MSI (Microsoft Installer) programs use their own Setup programs. These programs:

. Can be published to users only.

. Can NOT use elevated installation privileges.

. Can NOT be installed on the first use of the application.

. Can NOT install a feature on the first use.

. Can NOT roll back an unsuccessful operation.

. Can NOT use other MSI features.

To publish a non-MSI program:

1. Create a .zap file, using the following sample:

[Application]
; Only FriendlyName and SetupCommand are required,
; everything else is optional.

; FriendlyName is the name of the program that
; will appear in the software installation snap-in
; and the Add/Remove Programs tool.
; REQUIRED
FriendlyName = "Microsoft Excel 97"

; SetupCommand is the command line used to
; Run the program's Setup. If it is a relative
; path, it is assumed to be relative to the
; location of the .zap file.
; Long file name paths need to be quoted. For example:
; SetupCommand = "long folder\setup.exe" /unattend
; or
; SetupCommand = "\\server\share\long _
; folder\setup.exe" /unattend
; REQUIRED

SetupCommand = "setup.exe"

; Version of the program that will appear
; in the software installation snap-in and the
; Add/Remove Programs tool.
; OPTIONAL
DisplayVersion = 8.0

; Version of the program that will appear
; in the software installation snap-in and the
; Add/Remove Programs tool.
; OPTIONAL
Publisher = Microsoft
2. To publish the program, use the Default Domain (or Local) Group Policy and navigate to User Configuration / Software Settings / Software Installation.
3. Right-click Software Installation and press New.

4. Press Package.

5. Toggle Files of type to ZAW Down-level applications package (*.zap).  

6. Navigate to and select the .zap file and press Open.

7. Press Publish.

8. Press OK.
0
 
ampapaAuthor Commented:
"Group Policy installs" I'm unaware of how that works?

I was hoping more for a shortcut/batch/script to the uninstall and install routines associated with an Application. How can I shorten the mouse clicks need to remove an application and install an application?

MSIEXEC would be the way to go if I were pushing this out on the network for sure but I'm only talking about a couple of computers and the learning curve on using MSIEXEC seems steep.

0
 
jdeclueCommented:
So you need something to push the buttons for you. I am out of suggestions... sorry ;)

J
0
 
Debsyl99Commented:
Hi

Thanks for the assist but unless you had an msi file (and sadly you didn't) I didn't assist - seriously you should have left this open longer!

I'm on my weekend here (uk time) and was planning on picking this up again on Monday.  Sorry I wasn't more help,

Best wishes

Deb :))

(Oh and JD - great to see you're a clean-up volunteer now! But how on earth do you find the time??? - D ;))

0
 
jdeclueCommented:
Told you, I am bored... I put in my notice to leave my current position and for political reasons, they had requested a 6 week transition. So, I don't start at my new job until October 8, and I have nothing to do at this one :)
J
0
 
Debsyl99Commented:
Well that's EE's gain - if you ever have need of any enthusiastic net admins, female and with entertaining British accents - let me know eh? ;)
0
 
jdeclueCommented:
Ha... are you cute? (SO politically incorrect! but hey, I am a world away)... I am tired of looking at 40 yr old techno geeks!

J
0
 
ampapaAuthor Commented:
Well jdeclue made a good point that essentially it was as easy as pushing a few buttons... I'm lazy but not stupid... At least I don't think I am, stupid that is.

I decided to use the registry's uninstall information and create a batch file crude but it will work except for answering the YES/NO questions? Any ideas?

p.s. I love the British! 40 isn't that old unless your 18...
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 6
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now