Monday, November 23, 2009

Monitor Power Saver


Nearly all of us employ some power saving scheme while working with our PCs' like, switching off the monitors (physically); setting the screensavers to kick in after a preset duration, putting the system to stand-by or totally powering down the system.

Consider this scenario - you want to take a 5 minute break and your screensaver is set to kick in around 3 minutes. You don't want to put the system to stand-by or totally power down the system as the lag required to get the system up and working is bit annoying. (You may have set up an antivirus scan, update or download which you don't want to be bothered with while you power down). So, your best bet is to power down the monitor for the 5 min and switch it on when you are back or let the screensaver kick in (which would give you only (5-3) 2 minute of power saving).

Switching on and off (physically) the power switch of your monitor isn't a great idea, because on a long run it can damage the switch (Monitor switches aren't meant to take heavy duty switch on and off cycles. Present day monitors are so designed to be left on for hours, while the power saving strategy has to be implemented by the installed softwares).

Well, this was one question that has been bothering me quiet recently. Thankfully a quick google search took me to the right direction. Below I've provided a small program (in C++), that could help solve a situation like the one described above.

// PROGRAM TO TURN OFF MONITOR IN C++

#include
using namespace std;

int main()
{
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);
return 0;
}

//EOF

The source code and executable can be downloaded here (6.40 KB).
(Open the link in new tab/window and save file as PowerSaver.rar)

A little light on the SendMessage function.

LRESULT SendMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);

The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message.

Parameters:
hWnd - Handle to the window whose window procedure will receive the message. If you don't want to bother creating a window to send the message to, you can send the message to all top level windows (HWND_BROADCAST) or you can use GetDesktopWindow function sending the message to the desktop window.
Msg - Specifies the message to be sent (WM_SYSCOMMAND).
wParam - Specifies additional message-specific information (SC_MONITORPOWER).
lParam - Specifies additional message-specific information.
1 - the display is going to low power.
2 - the display is being shut off.
-1 - the display is being turned on (undocumented value).

This program should compile with almost any C compilers without any errors, to give you an efficient monitor friendly power management application.

When the program is executed it forces the display to go into 'power off' state and (program) is terminated. Upon mouse movement or keyboard activity, the display is restored.

Try linking the program with any key on your keyboard (multimedia keyboard) or put a shortcut to the program on your desktop or assign a keyboard shortcut for the program.

Thanks to all people out there who helped me with this program.

Friday, August 28, 2009

Who is in control?


Is it you or your OS or some non-responding program?

Quiet often I've come across questions like
- recently my computer have been real slow, like some application is taking up all the memory
- some annoying window keeps popping up every time I do this/that (or at start-up)
- my anti-virus/anti-spyware detects some infected file, but I can't find or delete it
- I'm not able to delete some file on my hard-disk, it says 'file in use'
and the list goes on...

Well, if you have come across some of these warnings go ahead.

Any problem can be effectively solved if you get to the root of the problem and for a computer user, getting to the root of the problem would equally mean identifying which application caused the problem and its exact location. This is exactly where Process Explorer comes in.

Process Explorer is one of the most powerful application available for Windows, one which gives you full details about all running applications at any instant. It is a freeware created by Sysinternals, which was recently acquired by Microsoft Corporation. Almost similar to Task Manager in Windows, the Process Explorer is much more powerful and efficient.


Screenshot 1 - Process Explorer main window


Screenshot 2 - Process Explorer system information

A few good reasons why you should try out Process Explorer

- To track down problems (use Find to list or search for resources, held by a process)
- Can be used to track down what is holding a file open and preventing its use by another program
- Find complete location and command line of a running application (Command Line)
- To find a process that is maxing out the CPU or the amount of resources used by a process (R.Click and Properties)
- Real time system activity and resource utilization (Ctrl+I)
- Pointing the mouse in the graph of CPU Usage in System Information gives the applications utilizing the CPU
- CPU activity graph for each process (R.Click any > Properties > Performance Graph)
- Suspend, kill or restart a selected process or process tree
- Use Window Title to detect open applications and status at Window status

These are just a few, but the real potential is much more. Just work with it a couple of times (advisable coz it is always good to differentiate between the legitimate applications from illegitimate ones and this comes with experience).

Process Explorer can also be triggered to open up instead of Task Manager when you press 'Ctrl+Alt+Del' and can also be fully customised to show the parameters you want.

There is no installation required, just download from the site (link given below), unzip and run the exe.

More Reading:
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx (Download link here)
http://en.wikipedia.org/wiki/Process_Explorer

Friday, June 26, 2009

Why go for Linux?


Open Source and Free
Linux is open source whereas Windows is closed source, i.e. you don’t have to pay a thing to install and use Linux (mostly all variants are free). Windows on the other hand costs you depending on the version you use.

Security
Windows being the most popular and widely used OS, most virus and malwares are designed for Windows so that they have the maximum reach. Although Linux versions aren’t totally virus free, the extend of possible damage (restricted to the rights of the user of the current session) is much lower in Linux based systems due to its modular design.

A quote from a QinetiQ research paper says:
The numbers differ in detail, but all sources agree that computer viruses are overwhelmingly more prevalent on Windows than any other system. There are about 60,000 viruses known for Windows, 40 or so for the Macintosh, about 5 for commercial Unix versions and perhaps 40 for Linux. Most of the Windows viruses are not important, but many hundreds have caused widespread damage. Two or three of the Macintosh viruses were widespread enough to be of importance. None of the Unix or Linux viruses became widespread – most were confined to the laboratory.
Analysis of the Impact of Open Source Software, Dr. Nick Peeling and Dr. Julian Satchell, October 2001. (Full report)

Popularity – Linux vs. Windows
Non – servers (user end systems)
Windows 89.5%, Linux 4.1%, Mac 6.1% & Rest 0.3%
(Servers are those which hosts websites and provide services)
Apache 66.65%, Microsoft 18.68%, Others 14.67%
(Majority of all web servers using Apache are Linux web servers)
(An infected server means loss of services, communication and income)
Based on statistics at:
http://www.w3schools.com/browsers/browsers_os.asp
http://news.netcraft.com/archives/2009/03/15/march_2009_web_server_survey.html

Stability
Linux based systems are more stable than the Windows variants, as an event of crash or hang is much lower in Linux. With Windows it is often needed to restart (usually after a software installation or security updates), but seldom does such a need arise in Linux.

More reading:
http://www.openworld.co.ke/opensource/why-open-source-software.html
http://www.theregister.co.uk/2003/10/06/linux_vs_windows_viruses/

Sunday, May 31, 2009

Fixing the USB Virus


Any USB device containing viruses can't just simply affect your system unless you let it. Nearly very USB virus works by a trigger, one that launches and activates it. As long as this trigger is not recieved, any USB device containing virus can be considered safe.


The most commonly found USB viruses gets triggered by a file called 'Autorun.inf' (usually found in an infected USB device). When you insert an USB device into the computer, Windows looks if AUTORUN.INF file is located in the root folder of this drive. If AUTORUN.INF is found, then Windows follows the instructions in this file (this is the case if Autoplay is enabled and by default it is enabled in every system).

The instructions found in this file is usually what to do when you open or explore the drive, which icon and label should be shown against the drive and so on. USB viruses often work by exploiting this file, like programming a virus to be run when you select open through the context menu (the menu you get when you right click a drive or folder).

Steps to fix.

1. Go to 'Run' (shortcut - Win key + R) type 'gpedit.msc'
2. On the Group Policy editor window that opens up, go to 'User Configurations'
Select 'Administrative Templates' and then 'System'. (Explorer like view - click '+' to select)
3. On the right window pane, right click 'Turn off Autoplay' and select 'Properties'
4. Select 'Enabled' radio button and select Turn off Autoplay on: All drives
5. Select 'Apply' then 'Ok' and close the 'Group Policy' window

The above procedure Disables Autoplay on USB drives (and CD/DVD drives) on a Windows XP machine. By turning off autoplay, Windows does not automatically run applications when you insert a USB device (and CD/DVD). So you are now protected against viruses that run immediately upon insertion of infected USB devices.

To open an infected USB device.

1. Plug in your USB device.
2. Open 'My Computer'. Here you see the USB drive (assume drive letter J:).
DO NOT RIGHT CLICK AND SELECT ANY OF THE CONTEXT MENU ITEMS NOR DOUBLE CLICK THE DRIVE ICON.
3. Go to Tools > Folder Options
Select 'View'. Enable 'Show hidden files and folders', untick 'Hide extensions for known file
types' and untick 'Hide protected operating system files'. (A warning window will appear,
select 'Yes'). Click 'Apply' and 'OK'.
(Autorun.inf usually have hidden and system attributes set).
4. Go to the Address bar and type 'J:\' (without quotes).
5. DELETE 'AUTORUN.INF' FILE (INFECTED DRIVES WILL HAVE ONE) AND ANY OTHER SUSPICIOUS EXE OR COM FILES THAT YOU DID NOT TRANSFER TO YOUR DEVICE.

VOILA!! Your USB device is now free of virus. Stop the USB drive, unplug and reinsert for use.

NB: To reset 'Folder Options' select 'Restore Defaults' (in View). Hidden and System files are only visible if the system is already free of virus infection. It is advisable to restore the View settings to default to prevent accidental deletion of system files.


Monday, March 9, 2009

Strange thing called 'DESTINY'


Ever wondered why you are reading this?

Haven’t it ever occurred to you that if doing something or taking a different step towards something at some point in your life might have changed what you are right now or what you might be doing right now?

Well, guess that defines Destiny.

Puzzling? That’s how it is supposed to be.

Destiny, no matter how ignorant we are about it defines and governs our life and others. Doing something right now is supposed to have an implication on what we did some time back in our past or sometime yet to come in our future. It also changes the life of those around and of total strangers (although appears to be strangers but their lives have something to do with yours).

Wasn’t there a time in your life when you took a decision in life which was against what you thought or believed and hasn’t that decision turned your life into a totally different course, like one single decision reflecting upon another, paving way to another action and so on?

The Almighty God defines and governs every living form in this universe. He is the ultimate power, one who decides and defines our life to events and situations long before we could even conceive it to be happening. That doesn’t mean that we should stop trying or stop aspiring about dreams in our life. It just means that no matter one does, one will always end up where one is supposed to.

Who knows perhaps that dreams and aspirations might sometimes modify your destiny.

Give it a little thought process and see the plot unfold.

NB: It might be such that the above abstract might not be in tune with everybodys' thoughts, but its how I feel and believe about life. Although difficult to conceive one might realize someday that what governs all our life is destiny.

Monday, February 23, 2009

Howdy


For long had I been prioritizing my tasks and making a blog just remained unaccomplished. Didn't know why I wanted to create one, but thought it would be great to reach out.

I would like to post here my thoughts and little knowledge on stuffs, other nick nacks and some abstract ideas that has for long been there in my head.

If you do find any interesting stuffs or have any query, please leave a post. I would be happy to help.

Thank you for being here 'n' do visit again.

Take Care.