Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you're just getting into VB.Net, how about creating a command-line program to do this for you?</p> <ol> <li>Create a Console App</li> </ol> <p>Paste this code:</p> <pre><code>Module Module1 Sub Main() Dim program = "" Dim drive As String = "" Try 'Get the commandLine, without thhis application name or the beginning space Dim commandLine As String = Environment.CommandLine.Replace(System.Reflection.Assembly.GetExecutingAssembly().Location, "").Replace("""", "").Substring(1) 'Get the DriveNAme part of the commaneLine Dim driveName As String = commandLine.Split(":"c)(0) drive = GetDriveByName(driveName) 'Get the Program Name part of the commandLine program = commandLine.Split(":"c)(1) If drive.Length = 0 Then Throw New Exception("No drive was found with the name '" + driveName + "'") Dim starter As New System.Diagnostics.ProcessStartInfo(drive + program) starter.UseShellExecute = True System.Diagnostics.Process.Start(starter) Catch ex As Exception Console.WriteLine("Failed starting " + drive + program + ". " + ex.Message) End Try End Sub ''' &lt;summary&gt;Returns the drive letter of the Fixed or Removable drive with the specified name&lt;/summary&gt; ''' &lt;param name="DriveName"&gt;&lt;/param&gt; ''' &lt;returns&gt;&lt;/returns&gt; ''' &lt;remarks&gt;&lt;/remarks&gt; Public Function GetDriveByName(ByVal DriveName As String) As String Dim returnDrive As String = "" For Each drive As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives() If (drive.DriveType = (IO.DriveType.Fixed Or IO.DriveType.Removable)) Then 'Only interested in removable drives If (drive.VolumeLabel.Equals(DriveName, StringComparison.OrdinalIgnoreCase)) Then 'This is our drive! returnDrive = drive.Name End If End If Next drive Return returnDrive End Function End Module </code></pre> <p>Then build give your application a nice name (e.g. StartByDriveName.exe) and compile it.</p> <p>You can now use it in a batch file:</p> <p><code>StartByDriveName &lt;driveName&gt;:&lt;path&gt;\ProgramName</code></p> <p>e.g. StartByDriveName MomsUSB:\Program Files\Excel.Exe</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload