running msi from within packaged file with elevated rights

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Carpe_diem
Posts: 22
Joined: Thu Jan 10, 2013 8:35 am

running msi from within packaged file with elevated rights

Post 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

jvierra
Posts: 14615
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: running msi from within packaged file with elevated righ

Post by jvierra »

Can't tell without seeing your script.

User avatar
Carpe_diem
Posts: 22
Joined: Thu Jan 10, 2013 8:35 am

Re: running msi from within packaged file with elevated righ

Post 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

User avatar
Carpe_diem
Posts: 22
Joined: Thu Jan 10, 2013 8:35 am

Re: running msi from within packaged file with elevated righ

Post by Carpe_diem »

I think i have to go after the LocalPackage instead of the string

jvierra
Posts: 14615
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: running msi from within packaged file with elevated righ

Post 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.

jvierra
Posts: 14615
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: running msi from within packaged file with elevated righ

Post 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

User avatar
Carpe_diem
Posts: 22
Joined: Thu Jan 10, 2013 8:35 am

Re: running msi from within packaged file with elevated righ

Post 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

User avatar
Carpe_diem
Posts: 22
Joined: Thu Jan 10, 2013 8:35 am

Re: running msi from within packaged file with elevated righ

Post by Carpe_diem »

thank you jvierra i try that right now

User avatar
Carpe_diem
Posts: 22
Joined: Thu Jan 10, 2013 8:35 am

Re: running msi from within packaged file with elevated righ

Post by Carpe_diem »

it does uninstall perfect , but it wont install the new msi

jvierra
Posts: 14615
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: running msi from within packaged file with elevated righ

Post 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
#

Locked