Solved

Windows Scripting to remove and install applications

Posted on 2004-09-03
15
202 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
[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
  • 6
  • 4
  • 4
  • +1
15 Comments
 
LVL 96

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 100 total points
ID: 11973741
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
ID: 11973851
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 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 9

Expert Comment

by:jdeclue
ID: 11974264
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
ID: 11975184
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
ID: 11975242
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
ID: 11975591
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
 
LVL 9

Expert Comment

by:jdeclue
ID: 11975928
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
ID: 11976236
"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
ID: 11976332
So you need something to push the buttons for you. I am out of suggestions... sorry ;)

J
0
 
LVL 20

Expert Comment

by:Debsyl99
ID: 11977112
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
ID: 11977139
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
ID: 11977176
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
ID: 11977200
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
ID: 11977678
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Suggested Courses

617 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