.net 从进程自动运行CD。启动

.net 从进程自动运行CD。启动,.net,windows,system.diagnostics,autorun,.net,Windows,System.diagnostics,Autorun,使用Process.Start和ProcessStartInfo模拟自动运行CD(或其他媒体)的最接近的方法是什么 我尝试过一些显而易见的事情,比如: // Just opens the folder Process.Start("F:"); // Ditto Process.Start(new ProcessStartInfo("F:") {UseShellExecute = true}); // Throws System.ComponentModel.Win32Exception: N

使用
Process.Start
ProcessStartInfo
模拟自动运行CD(或其他媒体)的最接近的方法是什么

我尝试过一些显而易见的事情,比如:

// Just opens the folder
Process.Start("F:");

// Ditto
Process.Start(new ProcessStartInfo("F:") {UseShellExecute = true});

// Throws System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation
Process.Start(new ProcessStartInfo("F:") {UseShellExecute = true, Verb = "autorun"});

显然,我可以解析
autorun.inf
文件来计算出所涉及的可执行文件,但我只是想知道是否有更简单的方法来完成它。

[检查文件是否存在]

Process.Start(@"F:\autorun.inf");
编辑:对不起,自动运行似乎是一个资源管理器功能。您必须自己解析该文件

Const DVD_DRIVE As String = "E:\"

If IO.File.Exists(DVD_DRIVE & "autorun.inf") Then
    Dim textreader As New IO.StreamReader(DVD_DRIVE & "autorun.inf")
    Dim sLine As String = ""

    sLine = textreader.ReadLine()
    Do While Not String.IsNullOrEmpty(sLine)
        If sLine.StartsWith("open=") Then
            Dim applicationstring As String
            Dim autorunapp As New Process()
            Dim startinfo As ProcessStartInfo

            applicationstring = sLine.Substring(5)

            startinfo = New ProcessStartInfo(DVD_DRIVE & applicationstring)

            startinfo.WorkingDirectory = DVD_DRIVE
            autorunapp.StartInfo = startinfo
            autorunapp.Start()

            Exit Do
        End If

        sLine = textreader.ReadLine()
    Loop

    textreader.Close()
End If

对我来说,这只会导致记事本打开文件的内容。