By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,882 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,882 IT Pros & Developers. It's quick & easy.

Making an Autorun DVD

programingguru
P: 1
Hello I am M. Sullivan II



Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  3.         Process.Start(C:\"Resources\w2ksp2.exe")
  4.     End Sub
  5.  
This path and file are on my computer.I am trying to build this with Visual Studio 2005. I am running Windows XP.I have heard of a Autorun CD creator and might try it.


My question is my DVDROM drive path letter is f. but I want it to find the files on the DVDROM drive in other computer. This way I run the Autorun DVD in another computer the DVDRON drive will search for that drive letter. The drive path is different in other computers. Based on OS.

All I am trying to do is create a Service pack DVD.
For my computer.

Thanks for any help on this project
May 19 '18 #1
Share this Question
Share on Google+
1 Reply


IronRazer
P: 82
An "AutoRun" is just a simple text file that is saved in the root of the DVD or CD itself which contains the exe file you want to run when the DVD or CD is inserted. A VB.Net program would not be needed to run the exe on the DVD or CD.

You can find info on creating an AutoRun.inf file at the links below.

Msdn - Creating an AutoRun-Enabled Application
Wikipedia - Autorun.inf

However, if you actually want to run an exe on a Dvd or Cd from your vb.net application and you want your application to find the Dvd-Rom or Cd-Rom which contains the exe, then you can use the DriveInfo Class to do that.

You can iterate through all the drives that are CD/DVD types and look for the filename of your exe file on them. For example...
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2.         For Each di As IO.DriveInfo In IO.DriveInfo.GetDrives 'iterate through all the drives avaiable
  3.             If di.IsReady AndAlso di.DriveType = IO.DriveType.CDRom Then 'check if the drive is ready and it is a CDRom type
  4.                 Dim ExeToFind As String = IO.Path.Combine(di.Name, "MyExeFile.exe") 'combine the drive letter with the filename of your specific exe file
  5.                 If IO.File.Exists(ExeToFind) Then 'check if your exe file exists on this CD/DVD
  6.                     Process.Start(ExeToFind) 'start the exe
  7.                     Exit For 'exe was found and started so, no need to keep looking, exit the loop
  8.                 End If
  9.             End If
  10.         Next
  11.     End Sub
  12.  
Or using the Where extension method...
Expand|Select|Wrap|Line Numbers
  1.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  2.         Dim drive As IO.DriveInfo = IO.DriveInfo.GetDrives.Where(Function(di) di.IsReady AndAlso di.DriveType = IO.DriveType.CDRom AndAlso IO.File.Exists(di.Name & "MyExe.exe")).FirstOrDefault
  3.         If drive IsNot Nothing Then
  4.             Process.Start(drive.Name & "MyExe.exe")
  5.         End If
  6.     End Sub
  7.  
Jun 1 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.