LJM89

any commands to run a ,exe setup or applcation pdf or flash files etc i am thinking of creating a autorun DVD menu to launch my setups and programs w/o using 3rd party software. possible


Re: Visual Basic Language Command to run .exe?

vsone

Check out (Google ):

System.Diagnostics.Process.Start("c:\app.exe")

This should start an app. Starting a .pdf, .doc, etc. is slightly more involved.

Hope this helps




Re: Visual Basic Language Command to run .exe?

Mohamed Shifaz

For example doc & xls:

For Microsoft Word files

System.Diagnostics.Process.Start("winword.exe " & mswordFileName)

For Microsoft Excel files:

System.Diagnostics.Process.Start("excel.exe " & excelFileName)






Re: Visual Basic Language Command to run .exe?

LJM89

thanks that will help.




Re: Visual Basic Language Command to run .exe?

jo0ls

You can just start them with the name of the file. File associations will start the app.

Process.Start("doc1.doc")

This has a benefit: if the user hasn't got word installed, then the system will pop up the standard dialog "Windows cannot open this file. What ya wanna do ".

Otherwise, if you try and start "winword.exe" and they don't have it, your app will throw an exception.

----
Doing it the other way, rather than concatenating strings to pass the arguments, you should use the correct override.

Process.Start("winword.exe", "doc1.doc")





Re: Visual Basic Language Command to run .exe?

LJM89

then if i want to run something from CD/DVD




Re: Visual Basic Language Command to run .exe?

Mohamed Shifaz

You can simply create an "autorun.inf" file within you CD. Inside you autorun.inf file place the following lines;

[autorun]

open=Filename.exe

icon=Filename.ico

* Where "Filename.exe" can be executable file and "Filename.ico" can be your autorun application's icon.






Re: Visual Basic Language Command to run .exe?

LJM89

i men the VB code to run a program from a CD. because all along i have to put C:\ or D:\ if the path changes, i have to change things right can i put something like %CDROM%/Folder/File.exe or a relative path like ../Folder/File.exe




Re: Visual Basic Language Command to run .exe?

Mohamed Shifaz

I sorry for not understanding your question. Please follow the code below it works fine for me.

Code Snippet

Imports System

Imports System.IO

Imports System.Diagnostics

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Not GetCDRomDriveLetter.Equals("null") Then

Process.Start(GetCDRomDriveLetter() & "TestLocation\TestApp.exe")

Else

MessageBox.Show("Cannot access to your CD/DVD Rom!","Cannot Access CD/DVD Rom",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)

End If

End Sub

Public Function GetCDRomDriveLetter() As String

GetCDRomDriveLetter = "null"

For Each drive_info As DriveInfo In DriveInfo.GetDrives()

If drive_info.DriveType = DriveType.CDRom Then Return drive_info.Name

Next

End Function

End Class

* Where TestLocation or TestApp.exe can be your CD/DVD Rom path to Application inside.