Page 1 of 2

running msi from within packaged file with elevated rights

Posted: Tue Oct 01, 2013 10:47 am
by Carpe_diem
Most likely I will have a dooogh moment the second someone can answer this for me, but here it goes anyway.......

I have a corrupted msi installation, so I want to create a packaged file which allows me to do the following
uninstall the existing prg and re-install again

MsiExec.exe /X{Drw8F69F-54A2-4280-AwrD-3E985E3wrFD9} /q
MsiExec.exe /i "C:\Temp\Filename.msi" /qn
gpupdate


I run it in cmd as only the CMD (run as admin) and it works fine

If I run it fom the packaged file it barks

setup as follows
from command line 32 bit
Powershell v2
Run as specified user : domain user with admin rights to the PC

So when I start the executable it opens a cmd prompt and the presents me with the msi help box
Windows ® Installer. V 5.0.7601.17514
msiexec /Option <Required Parameter> [Optional Parameter]

That is all it does, could someone please let me know what I am missing < i know it is realy easy :-)
Thank you in advance

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 11:05 am
by jvierra
Can't tell without seeing your script.

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 11:14 am
by Carpe_diem
its not realy a script more some uninstall msi and install msi
including (not realy powershell)

del "C:\Users\Public\Desktop\FIlename Desktop.lnk"
MsiExec.exe /uninstall {D38dad9F-54ad-aaad-A3AD-3E985fda3B3FD9} /passive
MsiExec.exe /i "C:\Temp\filename.msi" /passive
ren "C:\Users\Public\Desktop\filename.lnk" "newfilename.lnk"
gpupdate

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 11:29 am
by Carpe_diem
I think i have to go after the LocalPackage instead of the string

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 11:30 am
by jvierra
It is probable this line.

MsiExec.exe /uninstall {D38dad9F-54ad-aaad-A3AD-3E985fda3B3FD9} /passive

You will need to escape the {}
PowerShell Code
Double-click the code block to select all.
MsiExec.exe /uninstall `{D38dad9F-54ad-aaad-A3AD-3E985fda3B3FD9`} /passive
Try that. It may work.

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 11:36 am
by jvierra
This generally is easier:
PowerShell Code
Double-click the code block to select all.
$arglist='/uninstall {D38dad9F-54ad-aaad-A3AD-3E985fda3B3FD9} /passive'
Start-Process -FilePath msiexec.exe -ArgumentList $arglist

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 11:57 am
by Carpe_diem
found the uninstall string

$file = Get-WmiObject -Class win32_product | where { $_.Name -like "*filename*"}
$file.localPackage
msiexec /x $file.localPackage /passive


now the install

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 11:59 am
by Carpe_diem
thank you jvierra i try that right now

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 12:25 pm
by Carpe_diem
it does uninstall perfect , but it wont install the new msi

Re: running msi from within packaged file with elevated righ

Posted: Tue Oct 01, 2013 1:46 pm
by jvierra
mstrasser wrote:it does uninstall perfect , but it wont install the new msi
That is because the install starts before the uninstall is finished.

You can try the -wait switch
PowerShell Code
Double-click the code block to select all.
#
$arglist='/uninstall {D38dad9F-54ad-aaad-A3AD-3E985fda3B3FD9} /passive'
Start-Process -FilePath msiexec.exe -ArgumentList $arglist -Wait
#