2016-12-21 8 views
1

アプリケーションの再起動後に起動引数を使用するにはどうすればよいですか?C#ツールの再起動後に起動引数を使用する

は、私は次のように引数を渡している:

private void updateApplication(string tempFilePath, string currentPath, string newPath, string launchArgs) 
{ 
    string argument = "/C Choice /C Y /N /D Y /T 4 & Del /F /Q \"{0}\" & Choice /C Y /N /D Y /T 2 & Move /Y \"{1}\" \"{2}\" & Start \"\" /D \"{3}\" \"{4}\" {5}"; 
    ProcessStartInfo info = new ProcessStartInfo(); 

    info.Arguments = string.Format(argument, currentPath, tempFilePath, newPath, Path.GetDirectoryName(newPath), Path.GetFileName(newPath), launchArgs); 
    info.WindowStyle = ProcessWindowStyle.Hidden; 
    info.CreateNoWindow = true; 
    info.FileName = "cmd.exe"; 
    Process.Start(info); 
} 

今すぐツールがアップグレードしまうと、再起動が、どのように私は新しい再起動時にlaunchArgsに保存されている渡された引数を使用することができますか?

+0

新しい起動に引数を渡す – Steve

答えて

0

渡される引数は、エントリメソッドでアクセスできます。

class Program 
{ 
    static void Main(string[] args) 
    { 
      // args contains the arguments passed at startup. 
    } 
} 
+0

はい 'startUp.startUp(string [])'の必須の仮引数 'args'に対応する引数がありません – dnxc

+0

これはパラメータを取得しないためです更新後にのみ通常の起動時に渡されます。 – dnxc

+0

コマンドプロンプトを再起動しようとしていますか? – Agalo

0

あなたは既にそうしているようです。それらを何とかしたい場合は、あなたのインスタンスの変数に入れて、更新コマンドを取得したらそこから引き出して渡してください。

関連する問題