簡體   English   中英

在Windows中執行lsnrctl命令的程序?

[英]Program to execute lsnrctl command in Windows?

我想通過Windows平台上的C#程序執行lsnrctl status命令。 如果我使用此程序運行以獲取結果,它將不會給出結果。

static void Main(string[] args)
{
    System.Diagnostics.Process process = new System.Diagnostics.Process();

    var startInfo = new System.Diagnostics.ProcessStartInfo();
    startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    // the cmd program
    startInfo.FileName = "cmd.exe";
    // set my arguments. date is just a dummy example. the real work isn't use date.
    startInfo.Arguments = "/c date";
    startInfo.RedirectStandardOutput = true;
    startInfo.UseShellExecute = false;
    process.StartInfo = startInfo;
    process.Start();
    // capture what is generated in command prompt
    var output = process.StandardOutput.ReadToEnd();
    // write output to console
    Console.WriteLine(output);
    process.WaitForExit();

    Console.Read();
}

如何在Windows平台上檢查偵聽器狀態

從Windows oracle安裝目錄中提示lsnrctl.exe。 一旦在Windows系統上運行了lsnrctl.exe。 我可以通過鍵入偵聽器名稱來檢查偵聽器狀態。 LSNRCTL>狀態

它將給出默認監聽器的狀態。

同樣,我可以從提示符檢查任意數量的偵聽器狀態。 我想通過C#程序Windows平台對此進行檢查。

你好親近 不幸的是,您的命令date正在等待您輸入新日期。 如果按如下所示更改該行,則您的代碼應該可以正常工作:

startInfo.Arguments = "/c date /T";  // slash T means: just output the date

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM