Equivalent Command Of Ubuntu timeout 5s a.exe < input.txt For Windows







This is timeout command for Operating System to define maximum time for execution of a program .

Ubuntu Timeout Command

timeout 5s  a.exe < input.txt


Windows Command :

In windows it needs to make three batch file

**process.bat**

    
    @ECHO OFF
    start   /b cm.bat
    start  cmd.exe /c run.bat
    EXIT

**cm.bat**
  
   @ECHO OFF
    a.exe < input.txt > out.txt
    taskkill /im a.exe /f
    taskkill /im cmd.exe /f
    EXIT


**run.bat**

  
    @ECHO off
    timeout /t 5
    taskkill /im a.exe /f 
    taskkill /im cmd.exe /f

    EXIT


Now Run process.bat . it will start both cm.bat and run.bat simultaneously/parallely. When a.exe from cm.bat terminates; cm.bat kills run.bat and thus it will work as ubuntu timeout.

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment