Solved

Windows Scripting to remove and install applications

Posted on 2004-09-03
15
197 Views
Last Modified: 2010-04-14
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
Comment
Question by:ampapa
  • 6
  • 4
  • 4
  • +1
15 Comments
 
LVL 95

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 100 total points
Comment Utility
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
 
LVL 20

Assisted Solution

by:Debsyl99
Debsyl99 earned 200 total points
Comment Utility
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
 
LVL 20

Expert Comment

by:Debsyl99
Comment Utility
0
 
LVL 9

Expert Comment

by:jdeclue
Comment Utility
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
 
LVL 8

Author Comment

by:ampapa
Comment Utility
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
 
LVL 9

Expert Comment

by:jdeclue
Comment Utility
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
 
LVL 8

Author Comment

by:ampapa
Comment Utility
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 9

Expert Comment

by:jdeclue
Comment Utility
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
 
LVL 8

Author Comment

by:ampapa
Comment Utility
"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
 
LVL 9

Accepted Solution

by:
jdeclue earned 200 total points
Comment Utility
So you need something to push the buttons for you. I am out of suggestions... sorry ;)

J
0
 
LVL 20

Expert Comment

by:Debsyl99
Comment Utility
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
 
LVL 9

Expert Comment

by:jdeclue
Comment Utility
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
 
LVL 20

Expert Comment

by:Debsyl99
Comment Utility
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
 
LVL 9

Expert Comment

by:jdeclue
Comment Utility
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
 
LVL 8

Author Comment

by:ampapa
Comment Utility
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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now