Coding Thread, vb.net Run exe from Applications path in Coding and Web Development; Hi all,
Ok im making a little GUI to allow easy installation of smart notebook via a VB form. This ...
18th July 2008, 05:09 PM #1
- Rep Power
vb.net Run exe from Applications path
Ok im making a little GUI to allow easy installation of smart notebook via a VB form. This is going to be used as an autorun on a CD so i need to get the path that the exe is running from (the CD drive letter) then execute the MSI for smart notebook with a few switches.
This is what i have so far.
as you can see i have got the path that the exe is running from but i dont know how to integrate it with the process.start command.
Public Class Form1
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
MsgBox("Not here yet")
Private Sub btnSmart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSmart.Click
Process.Start("SmartTools.msi /Passive NOTEBOOK_ONLY=1")
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim AppPath As String
AppPath = Application.StartupPath
lblAppPath.Text = AppPath
IDG Tech News
18th July 2008, 07:31 PM #2
Give the code below a try. You didn't mention what vesion of VB you're using - the code below works on 2005, .Net Framework v2.
It's probably better to call msiexec.exe directly and then pass the msi file as a parameter. You can specify both a filename and parameters in the process.start method
You can get the full path to the MSI by using & to concatenate the application.startuppath and the MSI filename. You'll need to wrap the whole string in " " ( chr(34) ) in case there's any spaces in the path.
However, you might still have a couple of problems. Firstly, you will need to ensure that the .Net framework is installed on every machine you're going to run the CD on.
Also, I've not tested running it direct from CD, but you may have problems with the default .Net Code Access Security Policy preventing the EXE file from running from the CD Drive. The default policy allows .Net EXEs to run from C: drive but not from network drives for example. I'm not sure about CDROM drives. It can be changed but it's something you'd have to do on each machine before running the CD.
You'd probably be better off with a batch file or a VBScript.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myPath As String
Dim myMSI As String
myPath = Application.StartupPath & "\"
myMSI = Chr(34) & myPath & "Smarttools.msi" & Chr(34) & " /Passive NOTEBOOK_ONLY=1"
Process.Start("c:\windows\system32\msiexec.exe", " /i " & myMSI)
20th July 2008, 05:46 PM #3
- Rep Power
Thanks i will test this later tonight.
You would think it would allow exe to be run from CD as most games/apps have a little GUI then you click an install button and the msi is triggered.
I will report back with the results later.
20th July 2008, 05:56 PM #4
Why not make use of autorun.inf? It's a lot simpler.
Last Post: 8th September 2013, 03:43 AM
By Silverman in forum Web Development
Last Post: 2nd July 2008, 12:21 PM
By Jawloms in forum MIS Systems
Last Post: 26th October 2007, 04:17 PM
By ajbritton in forum MIS Systems
Last Post: 4th April 2007, 03:25 PM
By alan-d in forum Web Development
Last Post: 18th January 2007, 10:34 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)