I am certain that at some point in your work life - you wanted things to be automated to save you time, to think on the broader picture.
Now since many of you are working from home (WFH) and there are days when you just wake up to switch on you laptop so that you can make your self available!! Thus saving your self from the micro management that you might face.
How about if this thing can be automated with a simple script!!! Excited !!!
JUST FOLLOW as mentioned below:
Steps :
- Create two java classes
- A windows batch file.
Create Batch file :
Create a batch file on desktop using text editor
and paste the code as :
Start skype.exe param1
exit
Paste the below codes and text editor as separate java classes and run when done:
Scheduler
package org.project.main;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
public class tasksch
{
public static void main(String[] args) throws ParseException {
DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = dateFormatter.parse("2016-09-29 12:07:01");
Timer timer = new Timer();
timer.schedule(new run(), date);
}
}
Class 2
package org.project.main; import java.util.TimerTask; public class run extends TimerTask { @Override public void run() { // TODO Auto-generated method stub try { String path="cmd /c start <path to Batch file>"; Runtime rn=Runtime.getRuntime(); // @SuppressWarnings("unused") Process pr=rn.exec(path); } catch(Exception e) { System.out.println("adad"); } } }

No comments:
Post a Comment