Vb.net 在批处理文件中使用visual basic中的字符串

Vb.net 在批处理文件中使用visual basic中的字符串,vb.net,visual-studio-2010,batch-file,cmd,arguments,Vb.net,Visual Studio 2010,Batch File,Cmd,Arguments,我正在用VisualBasic编写一个程序,它将启动一个批处理文件,该文件可以做一些事情。我需要的是将一个参数从VisualBasic传递到批处理文件 以下是迄今为止我在visual basic中掌握的内容: If M.Msg = WM_DEVICECHANGE Then Select Case M.WParam Case DBT_DEVICEARRIVAL Dim DevType As Intege

我正在用VisualBasic编写一个程序,它将启动一个批处理文件,该文件可以做一些事情。我需要的是将一个参数从VisualBasic传递到批处理文件

以下是迄今为止我在visual basic中掌握的内容:

If M.Msg = WM_DEVICECHANGE Then
            Select Case M.WParam
                Case DBT_DEVICEARRIVAL
                    Dim DevType As Integer = Runtime.InteropServices.Marshal.ReadInt32(M.LParam, 4)
                    If DevType = DBT_DEVTYP_VOLUME Then
                        Dim Vol As New DEV_BROADCAST_VOLUME
                        Vol = Runtime.InteropServices.Marshal.PtrToStructure(M.LParam, GetType(DEV_BROADCAST_VOLUME))
                        If Vol.Dbcv_Flags = 0 Then
                            For i As Integer = 0 To 20
                                If Math.Pow(2, i) = Vol.Dbcv_Unitmask Then
                                    Dim Usb As String = Chr(65 + i) + ":\"
                                    MsgBox("New device found!" & vbNewLine & vbNewLine & "The drive letter is: " & Usb.ToString & vbNewLine & "Start backup?")
                                    Dim DosRun As Process = New Process
                                    Dim strArgs As String
                                    strArgs = Usb.ToString
                                    DosRun.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
                                    DosRun.StartInfo.FileName = "C:\Users\info\Desktop\Backup.bat"
                                    DosRun.StartInfo.Arguments = Usb
                                    DosRun.Start()
                                    Exit For
                                End If
                            Next
                        End If
                    End If
这是我的批处理文件的一部分:

xcopy %Usb% %ziel% /E /V /W /I /F /H /D /Y /EXCLUDE:C:\Users\info\Desktop\Exclude.txt

我需要将参数Usb传递到批处理文件。有人能帮我吗?

在批处理文件中,将
%Usb%
替换为
%1
,您就可以开始了。

在批处理文件中,通过输入
%
和参数编号捕获参数
%1
将是第一个参数,
%2
将是第二个参数,依此类推

只需将
%Usb%
更改为
%1
即可捕获第一个参数

xcopy %1 %ziel% /E /V /W /I /F /H /D /Y /EXCLUDE:C:\Users\info\Desktop\Exclude.txt