「値が割り当てられる前に変数 'strMap' が使用されています。実行時に null 参照例外が発生する可能性があります」という文字列 strMap のエラーを受け取るという問題があります。
値を適用する前に文字列を使用していると言っていることは理解していますが、コードからわかるように、If ステートメントの最後のセットで値を適用しています (これらは以前は If/Else でしたが、これはそれをいじっていたものでした。
その結果、strMap 文字列が空として動作するため、シェル コマンドで指定されたファイルを見つけることができません。
前もって感謝します。
デイモン
Private Sub btnCreateServerSimple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateServerSimple.Click
'Working code for server creation using pre-existing batch files
'Declarations
Dim strGameType As String
Dim strMap As String
Dim strServer As String
'Dim strBatchFile As String
Dim strBatchLoc As String
'Checking for selected server and setting strServer string accordingly
If cmbServerSimple.Text = "Server 1" Then
strServer = "server1"
strBatchLoc = frmInstallUpdateSettings.txtCSGOServer1BatchFilesLocation.Text
Else : cmbServerSimple.Text = "Server 2"
strServer = "server2"
strBatchLoc = frmInstallUpdateSettings.txtCSGOServer2BatchFilesLocation.Text
End If
'Checking for gametype and setting strGameType string accordingly
If cmbGameTypeSimple.Text = "Classic Competative" Then
strGameType = "classic_competative"
Else : cmbGameTypeSimple.Text = "Classic Casual"
strGameType = "classic_casual"
End If
'Checking for selected map and setting strMap string accordingly
If cmbMapSimple.Text = "de_aztec" Then
strMap = "de_aztec"
End If
If cmbMapSimple.Text = "de_dust2_se" Then
strMap = "de_dust2_se"
End If
If cmbMapSimple.Text = "de_dust" Then
strMap = "de_dust"
End If
If cmbMapSimple.Text = "de_inferno" Then
strMap = "de_inferno"
End If
If cmbMapSimple.Text = "de_nuke_ve" Then
strMap = "de_nuke_ve"
End If
If cmbMapSimple.Text = "de_mirage" Then
strMap = "de_mirage"
End If
If cmbMapSimple.Text = "de_train" Then
strMap = "de_train"
End If
If cmbMapSimple.Text = "de_vertigo" Then
strMap = "de_vertigo"
End If
Shell("C:\Users\Damon\Desktop\batchtest\" & strServer & "_" & strGameType & "_" & strMap & ".bat", AppWinStyle.NormalFocus)
End Sub