से शुरू होने पर कमांड लाइन पर आउटपुट मैं एक ऐसा एप्लीकेशन लिख रहा हूं जिसे मानक WinForms ऐप या कमांड लाइन से अनुपयुक्त मोड में शुरू किया जा सकता है। एप्लिकेशन वीएस 2 के 5 मानक WinForms टेम्पलेट का उपयोग कर बनाया गया था।कमांड लाइन
जब आदेश कमांड लाइन से निष्पादित किया जाता है, तो मैं इसे आउटपुट जानकारी देना चाहता हूं जिसे एप्लिकेशन को निष्पादित करने वाली स्क्रिप्ट द्वारा कैप्चर किया जा सकता है। जब मैं इसे सीधे कंसोल से करता हूं। राइटलाइन(), आउटपुट प्रकट नहीं होता है, हालांकि इसे फ़ाइल में पाइप करके कैप्चर किया जा सकता है।
दूसरी ओर, मैं कर्नेल 32 से AllocConsole() पर पी/Invoke करके दूसरे कंसोल को पॉप अप करने के लिए एप्लिकेशन को मजबूर कर सकता हूं। यह वही नहीं है जो मैं चाहता हूं। मैं चाहता हूं कि आउटपुट उसी विंडो में दिखाई दे जिसे एप्लिकेशन से कॉल किया गया था।
<STAThread()> Public Shared Sub Main()
If My.Application.CommandLineArgs.Count = 0 Then
Dim frm As New ISECMMParamUtilForm()
frm.ShowDialog()
Else
Try
ConsoleControl.AllocConsole()
Dim exMan As New UnattendedExecutionManager(ConvertArgs())
IsInConsoleMode = True
OutputMessage("Application started.")
If Not exMan.SetSettings() Then
OutputMessage("Execution failed.")
End If
Catch ex As Exception
Console.WriteLine(ex.ToString())
Finally
ConsoleControl.FreeConsole()
End Try
End If
End Sub
Public Shared Sub OutputMessage(ByVal msg As String, Optional ByVal isError As Boolean = False)
Trace.WriteLine(msg)
If IsInConsoleMode Then
Console.WriteLine(msg)
End If
If isError Then
EventLog.WriteEntry("ISE CMM Param Util", msg, EventLogEntryType.Error)
Else
EventLog.WriteEntry("ISE CMM Param Util", msg, EventLogEntryType.Information)
End If
End Sub