Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to run an .msi file using the Shell function, but I guess it doesn't like it.

 

Shell("C:\mySetup.msi", AppWinStyle.NormalFocus, True)

 

It gives me the following error:

 

------------------------------------

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in microsoft.visualbasic.dll

 

Additional information: File not found.

------------------------------------

 

 

Is there a way I can execute an .msi file with code?

 

Thanks!

  • *Experts*
Posted

Eek, don't use Shell... that's one of the old VB6 functions. Use

System.Diagnostics.Process.Start("C:\mySetup.msi")

 

But, if the error says the file is not found, then chances are you're

passing an incorrect filename.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

Awesome! Thanks a bunch!

 

Now, is there a way to wait for the process to finish (for the .msi installation to be closed) before giving the control back and executing the next line of code?

 

Thanks again!

  • *Experts*
Posted

Yeah. The static Process.Start() method returns a Process object,

which has a WaitForExit() method (how handy!).

 

Dim p As System.Diagnostics.Process

p = System.Diagnostics.Process.Start("C:\mySetup.msi")
p.WaitForExit()

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...