Jump to content

Recommended Posts

Posted

I need to uninstall an application from all of the machines on the network, before installing a new app. I have a command line instruction to do this ... but I have no idea how to send that instruction across the network short of physically/virtually visiting each machine :(

 

msiexec.exe /x {an-extremely-long-product-code} /q

 

I'm guessing that it could be at the start of the .mst for the new app. Could someone please advise?

Posted

How was said application allocated? Can you not 'de-allocate' it per say?

 

You can use psexec to connect to a machine and run that command you have there.

 

You'll need a list of applicable workstation names and a spreadsheet to create your lines to do it.

 

Or, you could depending upon what the application is and the environment your machines are in run that command in a start up script.

Posted
How was said application allocated?

 

Physically installed at differing times.

 

You can use psexec to connect to a machine and run that command you have there.

 

You'll need a list of applicable workstation names and a spreadsheet to create your lines to do it.

It might take me as long to type the list as visit each comp.

 

Or, you could depending upon what the application is and the environment your machines are in run that command in a start up script.

 

OK don't know much about running start up scripts, give me clue?

Posted

Start-up script's one option.

 

Or there's the psexec option, but using VBscript or Powershell to grab a list of all computers in the domain and dump their names into the psexec command line.

 

$strCategory = "computer"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("(objectCategory=$strCategory)")
$colProplist = "name"
foreach ($i in $colPropList)
{
$objSearcher.PropertiesToLoad.Add($i)
}
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
{
$objComputer = $objResult.Properties
Write-Host("Uninstalling from $objComputer.name")
& psexec [url="file://\\$objComputer.name"]\\$objComputer.name[/url] -u  -p  msiexec.exe /x {an-extremely-long-product-code} /q
}

 

You can take out the -u and -p bits if you don't need to run the uninstall under a specific account, or throw in a -s command to run it under the system account.

Posted
How was said application allocated? Can you not 'de-allocate' it per say?

 

You can use psexec to connect to a machine and run that command you have there.

 

You'll need a list of applicable workstation names and a spreadsheet to create your lines to do it.

 

Or, you could depending upon what the application is and the environment your machines are in run that command in a start up script.

 

Thanks for this and sorry to be such a dim brain but I don't know what to do with it.

Posted
Thanks for this and sorry to be such a dim brain but I don't know what to do with it.

 

psexec is a command-line tool for remotely running commands. You can find all the details on it here: PsExec

 

If you use the @file parameter you can specify a file with a list of computers which it'll then run the command against. If you don't have a file, you can use the PowerShell script above to pipe the output to a file instead of psexec and then use that list in the command.

  • Thanks 1
Posted

Do you have a machine startup script configured for machines in your domain? If so then you can add this to that script. if not, then now is a good time to get one :-)

 

In group policy management console, right click at the top of the domain and choose create and link a GPO here - call it something like "machine startup settings". Edit the GPO and under Computer Configuration, Windows Settings you'll find "Scripts Startup/Shutdown"

 

Double click on the startup option and you'll get a screen where you can add a script. I like to keep scripts for a GPO in the GPO folder (others don't ...) so click on show files to get an explorer window for this location. Right click and choose New text file. Name it "uninstall.cmd" (make sure it isn't uninstall.cmd.txt) and then edit it.

 

In the notepad window which comes up, paste in your uninstall command and save the script. Shutdown and restart a machine and at startup the batch file should run and uninstall your software.

 

(Note: it's probably safest to test this by initially linking your GPO to an OU with just one test PC in it - that way you don't mess up the entire network. The other thing is that this will run at every startup; ideally you only want it to run if it's not run before but if you can be sure that all the machines will be turned on in a day you can just leave it in place for one full day then remove the GPO)

  • Thanks 1
Posted
Brilliant, thanks Steve, that looks just the ticket. You guessed right in that I do not at the moment have any such scripts. Will take your step by step and test on one OU - fingers crossed that it works.
Posted

It worked :) Ran a test machine - software uninstalled, so far so good. Ran a GPO containing the new software - installed, even better. Logged on - software all there but ... it reminded me of the Fast Show. Interia - scortchio. Costa - scortchio. Unfortunately I'd used the wrong language.mst and I had Portugese instead of English. Still all is not lost, removed the GPO, restarted the test machine and it all uninstalled itself:)

 

Another day tomorrow to get it right. Someone once said "If a job's worth doing it's worth doing twice." Just got to hope that twice will be enough.

 

Thanks for the help.

Posted

If you can guarantee that all machines will be switched on "today" to do the uninstall and then "tomorrow" you remove that GPO and do the install then you can carry on like this.

 

Stage 2 is to develop the process so it copes with the situation where you're not sure when stuff will be switched on. In essence, you add a check to the process - there are loads of ways to do this but one would be to have a folder in which you put flag files.

 

Your uninstall batch file then looks something like this:

if not exist %windir%\schoolname md %windir%\schoolname
if exist %windir%\schoolname\packagename.1 goto end
msiexec.exe /x {an-extremely-long-product-code} /q
echo uninstalled > %windir%\schoolname\packagename.1
:end

 

First line just makes sure your flag file folder is there (call it what you want - if you use your school name then hopefully you'll remember what it's for :-))

Next checks for a flag file; if it's there you just skip to the end (put whatever the package is called; you can then use the same idea for different packages)

uninstall command exactly as before

Next line creates a flag file and just puts the word "uninstalled" in it; the date stamp on the file will show you when it ran if you ever need to know.

 

Why is there a ".1" at the end of the filename? Well, this allows you to just change it to ".2" when you need to remove this package and upgrade it (or when it all goes wrong and you need to do it a second time ...)

 

Now you've got a startup script, you'll find there are loads of other things you can do and you'll wonder how you ever managed without :-)

  • Thanks 1
Posted

My learning never stops, there's always something else :(

Tonight remotely, I've moved the uninstall script to the domain, started all the desktops and the software has gone from those machines, which I've now shut down. Tomorrow will be the turn of the laptops, there are more of those so may take some time to ensure all. Then I can move the startup script back to the test OU and try an edit as suggested.

 

Next job, turn all machines back on to install the new software - this time in English:)

 

Thanks for the continued assistance and support, it is very much appreciated.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...