Sunday 10 January 2016

Schedule,abort,reboot,shutdown in windows with cmd

Sometime after the software update windows automatically restart the system.(system will restart in 10 minutes) Or you may want to schedule shutdown or reboot of system.


To abort this shutdown: (before you know how to shutdown you should know how to abort)

shutdown -a or shutdown /a

Scheduling shutdown, reboot time for windows:

shutdown -s -t 30  (Shutdown will be in 30 sec)

shutdown -r -t 30 (Reboot will be in 30 sec)



Create batch file off above command:

shutdown.bat ( open notepad and write below save as shudown.bat file)

shutdown.exe -s -t -60

abort.bat ( open notepad and write below save as abort.bat file)

shutdown.exe -a

HackTips with shutdown.bat file:(first read solution)

If the shutdown.bat file is copied to "startup" folder of windows then whenever the system will start
the shutdown.bat file  command will run and system will shutdown. This will create shutdown loop the system will never start.

Where is startup folder(startup folder path)

Solution: 

Need to start windows in safe mode by pressing F8 key from your keyboard and we need to delete the shutdown.bat file from the startup folder.(in safe mode only basic programs are loaded)

Fun stuff:

Create shutdown.bat(with -t 00) file and send your friend and tell them to double click on that file to see magic or whatever.

Schedule shutdown time in some system.


Wednesday 6 January 2016

simple caesar cipher code in java

simple Caesar cipher code in java(encryption,decryption)

import java.io.*;
class cipher
{
 public static void main(String a[])
 {

  String s1,s2,cipher,alpha;
  int count=0;
  alpha="abcdefghijklmnopqrstuvwxyz";
  Console c=System.console();


  System.out.println("-----cipher----");
  s1=c.readLine("Enter the plain text :");
  s2=c.readLine("Enter the key(in number) :");
  System.out.println("---decryption---");
  int key=Integer.parseInt(s2);
  cipher="";

  for(int i=0;i<s1.length();i++)
      {
   for(int j=0;j<26;j++)
   {
     if(s1.charAt(i)==alpha.charAt(j))
      {
       cipher=""+alpha.charAt(j+key);
    System.out.print(cipher);
    }
   }

   }
   System.out.println("");
System.out.println("");
System.out.print(cipher);
System.out.println("");
System.out.println("");

   System.out.println("---decryption---");
 
   for(int i=0;i<cipher.length();i++)
      {
    for(int j=0;j<26;j++)
   {
     if(cipher.charAt(i)==alpha.charAt(j))
      {
       cipher=""+alpha.charAt(j-key);
    System.out.print(cipher);
    }
   }
   }
}
}