+ Reply to Thread
Results 1 to 3 of 3

Thread: process handling

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    34

    process handling

    I have a batch file and it does a certain function written on it , i want to start the batch file , wait for it to do instructions written on it then it should be exited , i want to continue the main program after the process is closed , i also want for the batch file process to be started hidden , i also used that code but it didn`t acquire what i needed :
    Code:
    string batfile = @"C:/Windows/System32/batchfunc.bat";
    ProcessStartInfo psi = new ProcessStartInfo(batfile);
    Process p = Process.Start(psi);
    so what i want to acquire is :
    1) start main program
    2) start batch file hidden
    3) pause main program
    4) wait for the batch file process to be done and closed
    5) resume main program
    Last edited by nadercoc; 01-10-2012 at 08:23 AM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    30
    if you want to start the process in background (i.e window is not visible) , then you should add :
    Code:
    psi.WindowStyle = ProcessWindowStyle.Hidden;
    and if you want to wait for the batch process to be exit to continue main program , then you should add :
    Code:
    p.WaitForExit();
    so the overall code should be exactly like that :
    Code:
    string batfile = @"C:/Windows/System32/batchfunc.bat";
    
    ProcessStartInfo psi = new ProcessStartInfo(batfile);
    psi.WindowStyle = ProcessWindowStyle.Hidden;
    
    Process p = Process.Start(psi);
    p.WaitForExit();

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    34
    Thank you it completely worked as i need , thank you very much again .

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts