Saturday, December 28, 2013

Mini project snake game in c

Mini project in C many Student do management project like library management ,Hotel management etc.But Snake Game is mini project of first semester build by my friend which is very different.It is console application without graphic library that's why it is more interesting.This game is perfect without any error and better user interface.It is complied in code::block using c language.Here goes a source code you can copy and compiled it in code::block.I hope it can help and become a reference for your project.



#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>
#include<time.h>
#include<ctype.h>
#include <time.h>
#include <windows.h>
#include <process.h>

#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77

int length;
int bend_no;
int len;
char key;
void record();
void load();
int life;
void Delay(long double);
void Move();
void Food();
int Score();
void Print();
void gotoxy(int x, int y);
void GotoXY(int x,int y);
void Bend();
void Boarder();
void Down();
void Left();
void Up();
void Right();
void ExitGame();
int Scoreonly();

struct coordinate{
    int x;
    int y;
    int direction;
};

typedef struct coordinate coordinate;

coordinate head, bend[500],food,body[30];

int main()
{

    char key;

    Print();

    system("cls");

    load();

    length=5;

    head.x=25;

    head.y=20;

    head.direction=RIGHT;

    Boarder();

    Food(); //to generate food coordinates initially

    life=3; //number of extra lives

    bend[0]=head;

    Move();   //initialing initial bend coordinate

    return 0;

}

void Move()
{
    int a,i;

    do{

        Food();
        fflush(stdin);

        len=0;

        for(i=0;i<30;i++)

        {

            body[i].x=0;

            body[i].y=0;

            if(i==length)

            break;

        }

        Delay(length);

        Boarder();

        if(head.direction==RIGHT)

            Right();

        else if(head.direction==LEFT)

            Left();

        else if(head.direction==DOWN)

            Down();

        else if(head.direction==UP)

            Up();

        ExitGame();

    }while(!kbhit());

    a=getch();

    if(a==27)

    {

        system("cls");

        exit(0);

    }
    key=getch();

    if((key==RIGHT&&head.direction!=LEFT&&head.direction!=RIGHT)||(key==LEFT&&head.direction!=RIGHT&&head.direction!=LEFT)||(key==UP&&head.direction!=DOWN&&head.direction!=UP)||(key==DOWN&&head.direction!=UP&&head.direction!=DOWN))

    {

        bend_no++;

        bend[bend_no]=head;

        head.direction=key;

        if(key==UP)

            head.y--;

        if(key==DOWN)

            head.y++;

        if(key==RIGHT)

            head.x++;

        if(key==LEFT)

            head.x--;

        Move();

    }

    else if(key==27)

    {

        system("cls");

        exit(0);

    }

    else

    {

        printf("\a");

        Move();

    }
}

void gotoxy(int x, int y)
{

 COORD coord;

 coord.X = x;

 coord.Y = y;

 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);

}
void GotoXY(int x, int y)
{
    HANDLE a;
    COORD b;
    fflush(stdout);
    b.X = x;
    b.Y = y;
    a = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(a,b);
 }
void load(){
    int row,col,r,c,q;
    gotoxy(36,14);
    printf("loading...");
    gotoxy(30,15);
    for(r=1;r<=20;r++){
    for(q=0;q<=100000000;q++);//to display the character slowly
    printf("%c",177);}
    getch();
}
void Down()
{
    int i;
    for(i=0;i<=(head.y-bend[bend_no].y)&&len<length;i++)
    {
        GotoXY(head.x,head.y-i);
        {
            if(len==0)
                printf("v");
            else
                printf("*");
        }
        body[len].x=head.x;
        body[len].y=head.y-i;
        len++;
    }
    Bend();
    if(!kbhit())
        head.y++;
}
void Delay(long double k)
{
    Score();
    long double i;
    for(i=0;i<=(10000000);i++);
}
void ExitGame()
{
    int i,check=0;
    for(i=4;i<length;i++)   //starts with 4 because it needs minimum 4 element to touch its own body
    {
        if(body[0].x==body[i].x&&body[0].y==body[i].y)
        {
            check++;    //check's value increases as the coordinates of head is equal to any other body coordinate
        }
        if(i==length||check!=0)
            break;
    }
    if(head.x<=10||head.x>=70||head.y<=10||head.y>=30||check!=0)
    {
        life--;
        if(life>=0)
        {
            head.x=25;
            head.y=20;
            bend_no=0;
            head.direction=RIGHT;
            Move();
        }
        else
        {
            system("cls");
            printf("All lives completed\nBetter Luck Next Time!!!\nPress any key to quit the game\n");
            record();
            exit(0);
        }
    }
}
void Food()
{
    if(head.x==food.x&&head.y==food.y)
    {
        length++;
        time_t a;
        a=time(0);
        srand(a);
        food.x=rand()%70;
        if(food.x<=10)
            food.x+=11;
        food.y=rand()%30;
        if(food.y<=10)

            food.y+=11;
    }
    else if(food.x==0)/*to create food for the first time coz global variable are initialized with 0*/
    {
        food.x=rand()%70;
        if(food.x<=10)
            food.x+=11;
        food.y=rand()%30;
        if(food.y<=10)
            food.y+=11;
    }
}
void Left()
{
    int i;
    for(i=0;i<=(bend[bend_no].x-head.x)&&len<length;i++)
    {
        GotoXY((head.x+i),head.y);
       {
                if(len==0)
                    printf("<");
                else
                    printf("*");
        }
        body[len].x=head.x+i;
        body[len].y=head.y;
        len++;
    }
    Bend();
    if(!kbhit())
        head.x--;

}
void Right()
{
    int i;
    for(i=0;i<=(head.x-bend[bend_no].x)&&len<length;i++)
    {
        //GotoXY((head.x-i),head.y);
        body[len].x=head.x-i;
        body[len].y=head.y;
        GotoXY(body[len].x,body[len].y);
        {
            if(len==0)
                printf(">");
            else
                printf("*");
        }
        /*body[len].x=head.x-i;
        body[len].y=head.y;*/
        len++;
    }
    Bend();
    if(!kbhit())
        head.x++;
}
void Bend()
{
    int i,j,diff;
    for(i=bend_no;i>=0&&len<length;i--)
    {
            if(bend[i].x==bend[i-1].x)
            {
                diff=bend[i].y-bend[i-1].y;
                if(diff<0)
                    for(j=1;j<=(-diff);j++)
                    {
                        body[len].x=bend[i].x;
                        body[len].y=bend[i].y+j;
                        GotoXY(body[len].x,body[len].y);
                        printf("*");
                        len++;
                        if(len==length)
                            break;
                    }
                else if(diff>0)
                    for(j=1;j<=diff;j++)
                    {
                        /*GotoXY(bend[i].x,(bend[i].y-j));
                        printf("*");*/
                        body[len].x=bend[i].x;
                        body[len].y=bend[i].y-j;
                        GotoXY(body[len].x,body[len].y);
                        printf("*");
                        len++;
                        if(len==length)
                            break;
                    }
            }
        else if(bend[i].y==bend[i-1].y)
        {
            diff=bend[i].x-bend[i-1].x;
            if(diff<0)
                for(j=1;j<=(-diff)&&len<length;j++)
                {
                    /*GotoXY((bend[i].x+j),bend[i].y);
                    printf("*");*/
                    body[len].x=bend[i].x+j;
                    body[len].y=bend[i].y;
                    GotoXY(body[len].x,body[len].y);
                        printf("*");
                   len++;
                   if(len==length)
                           break;
               }
           else if(diff>0)
               for(j=1;j<=diff&&len<length;j++)
               {
                   /*GotoXY((bend[i].x-j),bend[i].y);
                   printf("*");*/
                   body[len].x=bend[i].x-j;
                   body[len].y=bend[i].y;
                   GotoXY(body[len].x,body[len].y);
                       printf("*");
                   len++;
                   if(len==length)
                       break;
               }
       }
   }
}
void Boarder()
{
   system("cls");
   int i;
   GotoXY(food.x,food.y);   /*displaying food*/
       printf("F");
   for(i=10;i<71;i++)
   {
       GotoXY(i,10);
           printf("!");
       GotoXY(i,30);
           printf("!");
   }
   for(i=10;i<31;i++)
   {
       GotoXY(10,i);
           printf("!");
       GotoXY(70,i);
       printf("!");
   }
}
void Print()
{
   //GotoXY(10,12);
   printf("\tWelcome to the mini Snake game.(press any key to continue)\n");
  getch();
   system("cls");
   printf("\tGame instructions:\n");
   printf("\n-> Use arrow keys to move the snake.\n\n-> You will be provided foods at the several coordinates of the screen which you have to eat. Everytime you eat a food the length of the snake will be increased by 1 element and thus the score.\n\n-> Here you are provided with three lives. Your life will decrease as you hit the wall or snake's body.\n\n-> YOu can pause the game in its middle by pressing any key. To continue the paused game press any other key once again\n\n-> If you want to exit press esc. \n");
   printf("\n\nPress any key to play game...");
   if(getch()==27)
   exit(0);
}
void record(){
   char plname[20],nplname[20],cha,c;
   int i,j,px;
   FILE *info;
   info=fopen("record.txt","a+");
   getch();
   system("cls");
   printf("Enter your name\n");
   scanf("%[^\n]",plname);
   //************************
   for(j=0;plname[j]!='\0';j++){ //to convert the first letter after space to capital
   nplname[0]=toupper(plname[0]);
   if(plname[j-1]==' '){
   nplname[j]=toupper(plname[j]);
   nplname[j-1]=plname[j-1];}
   else nplname[j]=plname[j];
   }
   nplname[j]='\0';
   //*****************************
   //sdfprintf(info,"\t\t\tPlayers List\n");
   fprintf(info,"Player Name :%s\n",nplname);
    //for date and time

   time_t mytime;
  mytime = time(NULL);
  fprintf(info,"Played Date:%s",ctime(&mytime));
     //**************************
     fprintf(info,"Score:%d\n",px=Scoreonly());//call score to display score
     //fprintf(info,"\nLevel:%d\n",10);//call level to display level
   for(i=0;i<=50;i++)
   fprintf(info,"%c",'_');
   fprintf(info,"\n");
   fclose(info);
   printf("wanna see past records press 'y'\n");
   cha=getch();
   system("cls");
   if(cha=='y'){
   info=fopen("record.txt","r");
   do{
       putchar(c=getc(info));
       }while(c!=EOF);}
     fclose(info);
}
int Score()
{
   int score;
   GotoXY(20,8);
   score=length-5;
   printf("SCORE : %d",(length-5));
   score=length-5;
   GotoXY(50,8);
   printf("Life : %d",life);
   return score;
}
int Scoreonly()
{
int score=Score();
system("cls");
return score;
}
void Up()
{
   int i;
   for(i=0;i<=(bend[bend_no].y-head.y)&&len<length;i++)
   {
       GotoXY(head.x,head.y+i);
       {
           if(len==0)
               printf("^");
           else
               printf("*");
       }
       body[len].x=head.x;
       body[len].y=head.y+i;
       len++;
   }
   Bend();
   if(!kbhit())
       head.y--;
}

How to make a Quiz Game in Notepad


Code under here because Us Programmers aren't allowed to Share .bat files in the internet Code here
@echo off
color 0b
echo.
echo.
echo.
echo Welcome to Quiz Game!
echo 1)Start
echo 2)Exit
set /p type=
if %type%== 1 start1
if %type%== 2 exit1

:start1
cls
color 0b
echo <Question here.>
echo 1)Blah
echo 2)Yadda
set /p type=
if %type%== 1 goto correct1
if %type%== 2 goto wrong1

:correct1
cls
color 0a
echo Correct (you can add more things if you want)
pause

:wrong1
cls
color 0c
echo Type 1 to exit
set /p type=
if %type%== 1 exit1

:exit1
cls
echo GoodBye!
pause

And save it in some name .bat its excitation 

How to Make a Video Game With Cmd

  1. 1- Anything in apostrophes can be changed, it won't affect the game - don't accidentally type it in to the actual code.
  2. 2
  3. Open Notepad or any other coding programs-Geany, Notepad++, etcetera.Save the file as ‘My Game’.bat

  4. 3
    Start the Code. Start by typing:
    • @echo off
    • title ‘My Game’
    • color zz
    • if "%1" neq "" ( goto %1)
    • pause
  5. 4
    Add Colours. Now save it and run, it will come up with an error and all the different colour combinations. Find the one you like and type it in after “color”, instead of “zz”. A good combination is color 0A, it makes the text green and the background black.
  6. 5
    Create the Menu. To create the menu get rid of pause and type in:
    • :Menu
    • cls
    • echo ‘1. Start’
    • echo ‘2. Instructions’
    • echo ‘3. Exit’
    • set /p answer=‘Type the number of your option and press enter.’
    • if %answer%==1 goto ‘Start_1’
    • if %answer%==2 goto ‘Instructions’
    • if %answer%==3 goto ‘Exit’
  7. 6
    Creating ‘Exit’ and ‘Instructions’. To create the exit screen type in this:
    • :‘Exit’
    • echo Thanks for playing !
    • exit /b
    • Now for the instructions type in:
    •  :‘Instructions’
    • cls
    • echo ‘Instructions’
    • echo.
    • Then write:
    • echo ‘Your instructions here’
    • As many times as you like then type:
    • pause
    • goto Menu
  8. 7
    Begin the game. Type in a scenario:
    • :Start_1
    • cls
    • echo ‘You have run into bad guys. Their forces are:’
    • echo ‘3 farmers’
    • echo ‘You have a high chance of winning.’
    • set /p answer=‘Would you like to fight or run?’
    • if %answer%==‘Fight’ goto ‘Fight_1’
    • if %answer%==‘Run’ goto ‘Run_1’
  9. 8
    Fighting and Running. Now to make fighting and running:
    • :Run_1
    • cls
    • echo You ran away safely !
    • pause
    • goto ‘Start_1’
    • :Fight_1
    • echo You have chosen to fight.
    • echo The battle is waging.
    • goto Fight_1_Loop
    • :‘Fight_1_Loop’
    • set /a num=%random%
    • if %num% gtr 4 goto ‘Fight_1_Loop’
    • if %num% lss 1 goto ‘Fight_1_Loop’
    • if %num%==1 goto ‘Lose_Fight_1’
    • if %num%==2 goto ‘Win_Fight_1’
    • if %num%==3 goto ‘Win_Fight_1’
    • if %num%==4 goto ‘Win_Fight_1’
    • :‘Lose_Fight_1’
    • cls
    • echo Sorry, you lost the battle :(
    • pause
    • goto Menu
    • :‘Win_Fight_1’
    • cls
    • echo Congrats, you won the fight!
    • set /p answer=‘Would you like to save?’
    • if %answer%==‘Yes’ goto ‘Save’
    • if %answer%==‘No’ goto ‘Start_2’
    • :‘Save’
    • goto ‘Start_2’
    • Now you can repeat the code used in ‘Start_1’ to create a second fight and a third and fourth and so on.
    • Also when you type e.g. :Fight_1 you also have to make sure that parts that say goto Fight_1 stay the same as each other so if you change one you have to change both.
    • I don’t currently know how to do the save thing
    • Unable to launch is a very common error.

  • TIPS
  • Remember, whenever you want something to be seen by the player, you have to type echo in front of it.
  • Check your batch script carefully and you will notice the wrong thing.
  • Play your game along the way, even if you don't have the whole thing done. It will help you to see how what you type corresponds with what you get and detect errors.
  • If you need to get out during the middle of a test run of your game, type Ctrl-C.
  • Batch files in Windows can be put to many uses automating tasks, but writing a text game like this is a fun way to learn how they work.

Sunday, December 15, 2013

Make your Computer Welcome You

Make your Computer Welcome You

Do you watch movies? Have you always loved the way how Computers in movies welcome their users by calling out their names? I bet that you too would want to know how you can achieve similar results on your PC and have a computer said welcome.

Then you are at the right place, this article describes exactly how you can make your computer welcome you like this.

With this trick, you can make your Computer welcome you in its computerized voice. You can make your Windows based computer say "Welcome to your PC, Username."

Make Windows Greet you with a Custom Voice Message at Startup

To use this trick, follow the instructions given below:-

  1. Click on Start. Navigate to All Programs, Accessories and Notepad.
  2. Copy and paste the exact code given below.
Dim speaks, speech
speaks="Welcome to your PC, Username"
Set speech=CreateObject("sapi.spvoice")
speech.Speak speaks
     3.  Replace Username with your own name.
     4.  Click on File Menu, Save As, select All Types in Save as Type option, and save the file as Welcome.vbs or "*.vbs".
     5.  Copy the saved file.
     6.  Navigate to C:\Documents and Settings\All Users\Start Menu\Programs\Startup (in Windows XP) and to C:\Users\ {User-Name}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup (in Windows 8, Windows 7 and Windows Vista) if C: is your System drive. AppData is a hidden folder. So, you will need to select showing hidden folders in Folder options to locate it.
     7.  Paste the file.



 Make your Computer Welcome you at startup

Now when the next time you start your computer, Windows will welcome you in its own computerized voice.

Note: For best results, it is recommended to change sound scheme to No Sounds.
You can change the sound scheme to No Sounds by following the steps given below:-
  1. Go to Control Panel.
  2. Then click on Switch to Classic View.
  3. Then Click on Sounds and Audio Devices.
  4. Then Click on the Sounds Tab.
  5. Select No Sounds from the Sound Scheme option.
  6. If you wish to save your Previous Sound Scheme, you can save it by clicking Yes in the popup menu.
  7. Click on OK.
Change Sound Scheme to No Sounds

Try it yourself to see how it works. In my personal opinion, this is an excellent trick. Whenever I start my PC in front of anybody and the PC welcomes me, the fellow is left wondering how brilliant a computer do I have.

Cool JavaScript Tricks: Edit Websites in Browser (Live)

Cool JavaScript Tricks: Edit Websites in Browser (Live)

Imagine a world where you are a God and have ultimate control on what happens and more importantly, how it happens. Seems too good a dream. Now it has come true, at least for the online world.

JavaScript tricks
Using this trick, you will be able to edit any webpage live in your browser as if it was a Wiki and change the details according to your wish. Yes, you read that right. You can edit Google or even Facebook for that matter right in your browser and that too without requiring any technical know-how or getting deep into hacking and cracking.

Here is an example picture demonstrating the Google Homepage edited by me to say that I own Google.
Edit Websites Browser

This is just an example. You can use it for anything like showing wrong traffic stats or for fooling people by showing that someone said something about them on Facebook or Twitter. It depends only on your creativity. But I would advise you to stay ethical and use it for entertainment purposes only.

(Mozilla Firefox does not support this. If you use Firefox, you can use the bookmarklets given at the end of this post. If you use Google Chrome and the code does not seem to work, precede it with "javascript:" without quotes.)

To use this trick, all you need to do is just copy the code given below and paste it in your address bar after you have opened the website you wish to edit. And start editing.

javascript:document.body.contentEditable%20=%20'true';%20document.designMode='on';%20void%200
You can capture a screenshot by pressing the Print Screen key or by using the Snipping Tool if you use Windows 7 or Windows Vista. If you wish to again make the website non-editable to give a more authentic look, copy and paste the code given below in the address bar after you are done editing (does not work in Firefox).

javascript:document.body.contentEditable%20=%20'false';%20document.designMode='off';%20void%200

Or, alternatively you can use the following bookmarklets by dragging them to your Bookmarks bar.

1.  Edit this Website

2.  Done Editing

The editing that you do will however be temporary as it is not server-sided. You can also save the modified website through your browser by File>Save. This works on all common web browsers including Chrome, Firefox, Opera and Internet Explorer.

Know if your neighbours are stealing your Wifi connection

 Know if your neighbours are stealing your Wifi connection
command prompt codes
Command Prompt can let you know if someone is connected to your Local Area Connection and using it. Just follow the steps:- 
1) Open your browser and visit http://192.168.1.1 or http://192.168.0.1 depending on your router. 
2) Find the tab that mentions “Attached Devices” or something similar.
3) Find the computer name, IP address and MAC Address (sometimes called Physical Address or Hardware Address) of your computer using the previous trick.
4 )Compare it with those displayed by your router in Step 2. If you notice some strange devices, then your neighbour has been sneaking in on your internet connection and it is best to set a password.

How to Increase Firefox Speed, Make Firefox Faster

How to Increase Firefox Speed, Make Firefox Faster

Mozilla Firefox is one of the most popular web browsers in the world, and for good reason. In addition to it being free, Firefox provides a reliable and secure internet surfing experience that many people prefer over other browsers. But like those other browsers, Firefox’s speed can sometimes begin to deteriorate. When this happens, it might take you longer to load certain webpages or download certain files, which can be quite frustrating. If your Firefox speed is suffering, the following tips and shortcuts will help you increase your speed and get Firefox back to normal in no time at all.

Make Firefox faster

Quick Speed Tweaks

There are a few quick tweaks that can really increase the speed at which Firefox runs. First of all, you will want to open your Firefox browser. Go up to the address bar and type in "about:config," minus the quotation marks, of course. Once those words are typed, hit enter. Next you want to type "network.http" in the filter bar. When the settings pop up, double-click to change the "network.http.pipelining" setting to true. This should increase your browsing speeds, but may not work if you are running on a proxy server. If you are indeed using a proxy server, you should set "network.http.proxy.pipelining" to true as well by double-clicking on it. After that, change "network.http.pipelining.maxrequests" to 8. Changing this number to 8 will allow Firefox to load more than one item at once when you go to any given webpage.

For the next speed tweak, you will want to stay in the "about:config" menu, just like in the prior tweaks. Right-click anywhere in the window, select "new," then "integer" from the drop-down menu. Call the preference name "nglayout.initialpaint.delay," then change the value to the number 0. Adjusting this setting will lower the amount of time Firefox waits before displaying a webpage’s content. There are also many other settings that can be tweaked in the "about:config" menu. Some are very advanced and should only be altered by users who are very familiar with Firefox's settings.

If you have a lot of add-ons installed, Firefox could take a lot of time to startup. Removing useless extensions and plugins would help with that.

Other Firefox Shortcuts
Make Firefox faster

Some handy shortcuts can make your Firefox browsing experience a bit speedier. On your keyboard, hitting the spacebar while browsing will allow you to scroll down. Holding down the shift key plus the spacebar will do just the opposite and scroll your page up. Since Firefox is well known for its tabbed browsing, it would only make sense that there would be a shortcut for opening a new tab. To do this, just hold the control key and the letter "T." Hitting the "F5" key will reload any webpage for you. Holding control plus tab will take you to the next tab. Lastly, holding down the alt key plus the home key (above the numbers on your keyboard) will take you directly to your home page.

There are a few other shortcuts that exist for Firefox as well. If you use bookmarks, giving them keywords will allow you to access them much quicker. All you have to do is go to your selected bookmark and right-click on it. Choose "properties," enter an easy-to-remember keyword in the keyword field, then save it. When you type that keyword in your normal address bar, your bookmark will appear.

Also, when you wish to access a specific site on your computer, do not worry about typing the complete URL in the Firefox address bar. If you simply enter in the name of the website, such as "Google," then press control plus enter, the rest of the address (www and .com) will be filled in for you if the website has a .com domain. If the website has a .net domain, press shift plus enter. For .org websites, press control plus shift plus enter. Although these shortcuts can take some time to get used to, they can really save you time and make it easier to surf the web.

If you are having issues with your Firefox speed, take a few minutes to familiarize yourself with these tweaks and shortcuts. Once you see how easy it can be to increase your Firefox speed, you will be glad you took the time to check them out.

Shutdown Your Computer or a Remote PC via Command Prompt

Shutdown Your Computer or a Remote PC via Command Prompt

Most of us shutdown our computers using the power button given in the Start menu. Some of us use the physical power button on our machines. Very few people actually use other means of shutting down a computer and even less is the number of people who use the command prompt to shutdown a computer.

A reason for this is that most of us don't know that the command prompt can be used to not only shutdown, restart or log off our computer instantly but also to shutdown a remote computer provided you have administrative access. It can also be used to hibernate a computer and give a comment containing the reason for shutdown. This post will show you how to do all this.

Shutdown computer with command prompt
Required
A computer running Windows (XP, Vista, 7 or 8) with the command prompt working perfectly, i.e. not disabled by a virus.

Initial Steps 
1) Press Windows Key + R.
2) Enter CMD and press Enter.

This will start the command prompt. Follow the instructions below depending on what you want to do.

Shutdown Local Machine (Your Computer)
Type "shutdown -s" without the quotes in the command prompt and press Enter. Shutdown is the command being executed and the switch -s tells the computer to shutdown.

Restart your Local Computer 
Type "shutdown -r" in the command prompt and press Enter. In this case, the command switch -r is telling the computer to restart after shutdown.

Log Off the Current User
Type "shutdown -l" in the command prompt and press Enter. The -l command switch tells the computer to log off.

Shutdown a Remote Computer
Type "shutdown -s -m \\name of the computer" in the command prompt and press Enter. Replace \\name of the computer with the actual name of the remote computer you are trying to shutdown. As mentioned earlier, you must have administrative access to the computer you are trying to shutdown. To know if you have administrative access, press Windows key + R and then type the name of the computer and press Enter.

Note: If you don't remember the name of the remote computer, you can look for it by opening a list of all the computers you are connected to by executing "net view" in command prompt.

If you can connect to the computer, you will be asked to login with your username and password. Upon entering them, a window will display the list of all the directories available to you. This should help you know whether you can or cannot shutdown the remote computer.

Hibernate a Local Computer
Type in "Rundll32.exe Powrprof.dll,SetSuspendState" without the quotes and press Enter. Your computer should hibernate, if it does not, then you must enable hibernation to do this.

Shutdown your or a remote computer after a specific time
Type "shutdown -s -t 60" to shutdown your computer after 60 seconds. Upon executing this, a countdown timer displaying a warning message will be shown. This command uses the -t command switch followed by a variable (which is 60 in this case) which represents the number of seconds after which the computer will shutdown.

Display a Message containing the reason for shutdown
Type shutdown -s  -t 500 -c "I am tired. I don't want to work anymore." (with the quotes) in the Command Prompt and press Enter. The -c switch is used in the code to give the reason for shutting down and what is followed in quotes will be displayed in the dialog box as the reason. This can be used to display all sorts of funny messages. One example :-

Skynet has become self aware. John Connor did not stop me. You can not use your PC anymore.

Stop a System Shutdown
Type "shutdown -a" and press Enter. This will stop the system from shutting down if the countdown to shut down has not reached 0.

How to Start Windows in Safe Mode Easily

How to Start Windows in Safe Mode Easily

Safe Mode is a special diagnostic mode in which Windows runs with the minimum amount of features. As the features are limited, Windows does not load unnecessary startup items and runs only those files and drivers that are necessary for the basic functioning of the operating system. This allows users to remove recently installed programs that might be preventing Windows from starting correctly. As Windows does not start unnecessary programs while in Safe Mode, Safe Mode can also be used to remove viruses and malware that cannot be removed normally without risking the infection getting worse.

Start Safe mode Windows
There are different ways in which you can get into the Safe Mode in Windows. They depend on the version of Windows you are using.

In this article:
  1. Steps for Windows 8 users
  2. Steps for Windows 7, Windows Vista, Windows XP and users of previous versions
  3. Force Windows to start in Safe mode
  4. Which Safe Mode option should you choose?

Windows 7, Windows Vista, Windows XP and Previous versions

If you are using these versions of Windows, you can try the following methods.

The Trusted F8 key method
1) Restart your computer if it is on.
2) Right before the system starts to boot, start tapping the F8 key continuously.
3) This should load the Windows Advanced Options boot menu.
4) Select a Safe Mode option based on your need using the arrow keys and press Enter.
5) Windows will start in Safe mode. To get out of Safe mode, simply restart your computer.

This method should work on Windows 7, Windows Vista, Windows XP, Windows 2003 and Windows ME. However, if it does not, you can always force Windows to boot in Safe Mode if your computer is working "properly".

Faulty Startup Method
If the F8 key method does not take you to the Advanced Options boot menu, you could try turning yourcomputer off when it boots into Windows. Upon next restart, Windows will notice that the computer did not boot successfully and take you to the Advanced Options boot menu. Then, select a Safe mode option based on your need. This method is risky and should only be tried as a last resort. It could result in some of your files being deleted which could make your Windows installation unusable.

Windows 8

The F8 key method does not work on Windows 8. Hence, getting onto Safe Mode requires the following steps:-

If your PC is working properly:
1) On Windows 8 Start Screen, type Advanced. In the search results, click on the Settings category.
2) Click on Advanced startup options.
3) Under the Advanced Startup heading at the bottom of the General Settings screen, click on Restart now.
4) Your computer will restart and you will be taken to the Advanced Startup Options menu. To easily reach this menu, on Windows 8 start screen, you could choose restart while holding the Shift key.
5) Click on Troubleshoot and then on the Advanced Options button.
6) Now, click on Startup Settings.
7) At the Startup Settings Screen, click on Restart.
8) Your computer will restart to Advanced Boot options from where you can choose a Safe mode optionbased on your need.

Windows 8 Safe mode

You can also force Windows to start in Safe mode.

If your PC is not working properly:
Windows 8 monitors your PC's startup for problems and when an error is detected, it automatically takes you to the new Recovery mode with the message "Recovery. It looks like Windows didn't load correctly." In this case:-

1) Select Advanced Repair Options and then click on Troubleshoot.
2) Click on the Advanced Options button.
6) Now click on Startup Settings.
7) At the Startup Settings Screen, click on Restart.
8) Your computer will restart to Advance Boot Options from where you can choose a Safe mode optionbased on your need.

Force Windows to restart in Safe Mode using the System Configuration Utility

Most users looking to boot Windows in safe mode will have a computer that is not working properly. Unfortunately, this method will not help them as it requires the user to have a working computer.

Start Windows in Safe mode

Steps:
1) On Windows 7, Windows Vista, Windows XP and previous versions of Windows, click on Start. Go to Run in Windows XP and previous versions and go to Search in Windows 7 and Vista. On Windows 8, go to the Start screen.
2) Type msconfig and press Enter.
3) This will start the System Configuration Utility.
4) On Windows XP, go to the BOOT.INI tab and check /SAFEBOOT. On Windows 8, Windows 7 and Windows Vista, go to the Boot tab and check Safe Boot.
5) Click OK.
6) Click on Restart in the following dialog box.-

Your computer will restart in Safe mode.

Different Safe Mode Options. Which to choose?

These are the various safe mode options available in Windows. You can choose one based on the features you require.


Safe Mode
This is safe mode in its most basic form without any extra features. It is useful for troubleshooting most common problems .

Safe Mode with Networking
This offers additional support of connecting to the internet or any other network. This is useful when your PC has a problem which might require you to frequently use the internet to troubleshoot.

Safe Mode with Command Prompt
This option will allow you to use all the unique features of the Windows command prompt while in Safe mode.

Add Background Images to Folders in Windows

Suppose you have a music folder that contains all songs by your favorite singer. Would it not be great if instead of the plain white background, you could add the singer's image as the background of this folder? 

It is relatively easy to add background images to folders using a simple desktop.ini trick just as easily as you can change your Desktop's background. 

Desktop.ini is a system file that is used to customize the appearance and behavior of folders in Windows. We can use this ability of desktop.ini files to add backgrounds to folders just by adding a few lines of code. 

Folder Background in Windows
This is how the background in folder looks like.

Steps for adding backgrounds to Folders
  1. Open Notepad.
  2. Copy and paste the following code:-
  3. [{BE098140-A513-11D0-A3A4-00C04FD706EC}] iconarea_image="location of the image"
  4. You need to slightly modify this code on Windows Vista and Windows 7 as the ability to add folder backgrounds has been removed. So, if you use these versions of Windows, install AveFolder and then, replace [{BE098140-A513-11D0-A3A4-00C04FD706EC}] with [AveFolder] in the above code. To install this app, extract all the files and then, open the folder according to your installation of Windows (32 bit or 64 bit), right click install.bat and select Run as Administrator.
  5. In this code, iconarea_image is the parameter where the location of your image will go.
  6. Save the file as desktop.ini.
  7. Place this file in the folder where you want your personalized background.
  8. On Windows XP, you need to add system attribute to the folder where you want a background. To do this, open command prompt and execute "attrib +s D:\Music" (without quotes) if "D:\Music" is the location of your folder. If there are spaces in the location of your folder, you need to add double quotes around it. Windows Vista and 7 users need not add system attribute to folders.
  9. You might need to log off and log back on for the changes to take effect. Sometimes, AveFolder app fails to work in which case you need to restart Windows Explorer. I recommend you to create a System Restore point in case you do not like the results.

You can hide this desktop.ini file if you feel that it is something that should not be visible in your folder.

Tip: I am using this trick to have a personal picture as the background of the root folder of my flash drive. So, whenever I connect it to my Windows PC, the picture is displayed as the background. You can also do this but you should have the image in the drive itself. As you cannot assign a static location to the iconarea_image parameter (as the drive could be G:/ on one computer while F:/ on the other), you need to add the image's dynamic location. To do this, add "/{location of the image in flash drive}" as the value of iconarea_image. For example, if your image is located in the Pics folder in the flash drive, you need to have this value as:-

iconarea_image=/Pics/Image.jpg

It is important to note that the background to your flash drive will only be displayed on computers running Windows XP (if you have used the code for XP) or those computers running Windows 7 andWindows Vista that have AveFolder installed. Sadly, there is no way to make the background of your flash drive visible on all computers unless you modify your flash drive to automatically install this app on every PC you plug it in.

If this trick does not work for you, do add a comment.