Monday, October 29, 2007

[windows] Shutdown Windows Automatically

Following are the steps to create the scheduled task to shutdown the windows in specified time:
1.Click Start, and then click Control Panel.
2.Click Performance and Maintenance, and then click Scheduled Tasks.
3.Double-click Add Scheduled Task. The Scheduled Task Wizard starts.
4.Click Next.
5.Under Click the program you want Windows to run, click Browse.
6.In the Select Program to Schedule dialog box, locate the %SystemRoot%\System32 folder, locate and click the Shutdown.exe file, and then click Open.
7.Under Perform this task, specify a name for the task and how frequently you want this task to run, and then click Next.
8.Under Select the time and day you want this task to start, specify a start time and date for the task, and then click Next.
9.Type the user name and password to run this task under, and then click Next.
10.Click to select the Open advanced properties for this task when I click Finish check box, and then click Finish.
11.Click the Task tab.
12.In the Run box, specify any additional parameters that you want to use with Shutdown.exe.
13.Click OK

Tuesday, October 23, 2007

Recommended Add-ons for Mozilla Thunderbird

Following are the recommended add-ons for Mozilla Thunderbird:
  • XNote
    Persistent sticky notes for Thunderbird associated to mails.

  • Clippings
    Saves and manages frequently-entered text for later pasting into forms and input fields without the hassle of retyping or repetitive copying and pasting. Perfect for forms, web mail, blogging, wiki editing and forum posts.

  • ReminderFox
    An extension that displays and manages lists of date-based reminders and ToDo's. ReminderFox does not seek to be a full-fledged calendar system. In fact, the target audience is anybody that simply wants to remember important dates (birthdays, anniversaries, etc) without having to run a fat calendar application.

  • Auto Zip Attachments
    Allows you to easily compress (zip) attachments. A new button named "AutoZip" is added to the compose toolbar.
    Upon pressing the button all the attachments would be compressed into a single file. Then the attachments are replaced with the zipped file.

  • Attachment Extractor
    Just select the messages containing the attachments you want to extract and select 'Extract Attachments' and this extension does the rest. No more having to go through each message to extract the attachments!

  • ConfirmFolderMove
    Introduces a preference that allows users to be prompted before moving folders.

  • Enigmail
    Enigmail adds OpenPGP message encryption and authentication to your email client. It features automatic encryption, decryption and integrated key management functionality. Enigmail requires GnuPG (www.gnupg.org) for the cryptographic functions.
    Note: GnuPG is not part of the installation.

  • NotToForward
    Enables you to avoid sending mail to specific recipients.

  • SenderFace
    Enables you to associate images (faces) with Email senders (from field).

Recommended Add-ons for FireFox

Following are the recommended Add-ons for FireFox:
  • WebDeveloper
    Adds a menu and a toolbar with various web developer tools.

  • FireBug
    Firebug integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

  • GSpace
    This extension allows you to use your Gmail Space (2.8 GB and growing) for file storage. It acts as an online drive, so you can upload files from your hard drive and access them from every Internet capable system. The interface will make your Gmail account look like a FTP host.

  • FlashGot
    Download one link, selected links or all the links of a page together at the maximum speed with a single click, using the most popular, lightweight and reliable external download managers. Supported download tools are dozens, see http://flashgot.net for details. This extension offers also a Build Gallery functionality which helps to collect in a single page serial movies and images scattered on several pages, for easy and fast "download all".

  • Clipmarks
    With Clipmarks, you can clip the best parts of web pages. Whether it's a paragraph, sentence, image or video, you can capture just the pieces you want without having to bookmark the entire page.
    You can save your clips privately or publicly, email them to friends, or post them directly to your blog. Our new ClipSearch feature lets you search based on matching keywords inside the content you clip, as well as any tags, titles and descriptions you add. In effect, by clipping the best parts of Web pages, you build a personal search engine for the things that matter to you.

  • iMacros
    The Web browser is probably the most frequently used software today, and many tasks are highly repetitious. iMacros for Firefox relieves the repetition of checking on the same sites every day, remembering passwords and filling out web forms. Web professionals can use the software for functional testing and regression web testing of web applications. Another use is to automate web scraping, for example online stock quotes or web store prices.

  • VideoDownloader
    Download videos from Youtube, Google, Metacafe, iFilm, Dailymotion and other 60+ video sites ! And all embedded objects on a webpage (movies, mp3s, flash, quicktime, etc) ! Directly.

Friday, October 5, 2007

[windows] Shutdown Windows Using Script

Sub ShutDown()
Dim Connection, WQL, SystemClass, System

'Get connection To local wmi
Set Connection = GetObject("winmgmts:root\cimv2")

'Get Win32_OperatingSystem objects - only one object In the collection
WQL = "Select Name From Win32_OperatingSystem"
Set SystemClass = Connection.ExecQuery(WQL)

'Get one system object
'I think there is no way To get the object using URL?
For Each System In SystemClass
System.Win32ShutDown (2)
Next
End Sub
Value Meaning
0 Log Off
0 + 4 Forced Log Off
1 Shutdown
1 + 4 Forced Shutdown
2 Reboot
2 + 4 Forced Reboot
8 Power Off
8 + 4 Forced Power Off


Simple extension to shutdown remote computer.
Sub ShutDownEx(Server, User, Password)
Dim Connection, WQL, SystemClass, System

'Get connection To remote wmi
Dim Locator
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Connection = Locator.ConnectServer(Server, "root\cimv2", User, Password)

'Get Win32_OperatingSystem objects - only one object In the collection
WQL = "Select Name From Win32_OperatingSystem"
Set SystemClass = Connection.ExecQuery(WQL)

'Get one system object
'I think there is no way To get the object using URL?
For Each System In SystemClass
System.Win32ShutDown (2)
Next
End Sub

http://www.motobit.com/tips/detpg_wmi-windows-system-shutdown/

Wednesday, October 3, 2007

[mssql] 4 Simple Rules for Handling NULLs

Introduction

"As we know,
There are known knowns.
There are things we know we know.
We also know
There are known unknowns.
That is to say
We know there are some things
We do not know.”- Donald Rumsfeld

In a recent article by James Travis, the handling of NULLs in SQL Server was explored. I discovered some inaccuracies in the article; some caused by inaccuracies in SQL Server Books Online, others rooted in trying to apply other standard 3GL and 4GL programming language two-valued logic to the three-valued logic employed by ANSI SQL.

This article was written to explain ANSI SQL three-valued logic and correct the inaccuracies presented

What is NULL?

First, let's start by defining what a NULL is in SQL-speak. ANSI-SQL defines NULL as "a special value, or mark, that is used to indicate the absence of any data value." (ANSI-92) NULL in SQL is not a "data value", but rather an indicator that we have missing data. As an example, we’ll look at the following table which contains last name, first name and middle name.

Last_Name First_Name Middle_Name
'Smith' 'Linda' 'Anita'
'Washington' 'Larry' ''
'Jones' 'John' NULL

In this example, we know that Linda Smith has a middle name, and we know that it is 'Anita'. We have populated Larry Washington's Middle_Name column with a Zero-Length String ('') indicating that we know for a fact Larry has no middle name. These are the "known knowns" in Rumsfeld-speak.

In the case of John Jones, however, we have set the Middle_Name column to NULL. This indicates that we do not know whether John has a middle name or not. We may discover, in the future, that John has a middle name; likewise, we may discover he has no middle name. In either case, we will update his row accordingly. So, NULLs represent our "known unknowns"; the only thing we know for a fact is that we do *not* know whether John has a middle name or not.

Because of the inherent issues surrounding NULLs and data integrity, three-valued logic, scalar arithmetic and performance, DBA's and Database Designers tend to try to minimize the use of NULLABLE columns in their tables.

Rule #1: Use NULLs to indicate unknown/missing information only. Do not use NULLs in place of zeroes, zero-length strings or other "known" blank values. Update your NULLs with proper information as soon as possible.

Three-Valued Logic

Always in the Top 10 List of the most confusing aspects of ANSI SQL, for those coming from other 3GL and 4GL languages is three-valued logic. Anyone coming from a background in most other computer languages will instantly recognize the two-valued logic table:

Two-Valued Logic Table
p q p AND q p OR q
True True True True
True False False True
False True False True
False False False False

And of course the logic for NOT is fairly simple:

Two-Valued NOT Logic Table
p NOT p
True False
False True

So what is Three-Valued Logic? In SQL three-valued logic, we introduce the concept of Unknown into our logic, which is closely associated with NULL. Our SQL Logic Table looks like this:

Three-Valued Logic Table
p q p AND q p OR q
True True True True
True False False True
True Unknown Unknown True
False True False True
False False False False
False Unknown False Unknown
Unknown True Unknown True
Unknown False False Unknown
Unknown Unknown Unknown Unknown

And in SQL logic, the NOT logic table looks like this:

Three-Valued NOT Logic Table
p NOT p
True False
False True
Unknown Unknown

So how do we arrive at Unknown in these logic tables? Simply put, we try to compare NULLs to data values, or other NULLs. Per the ANSI-92 SQL Standard, comparisons with NULL always result in Unknown.

Try the following SQL Query in Query Analyzer (requires the Northwind Sample Database):

SET ANSI_NULLS ON
SELECT * FROM [Northwind].[dbo].[Employees]
WHERE [Region] IS NULL
This query returns four employee records. Now try this query:
SET ANSI_NULLS ON
SELECT * FROM [Northwind].[dbo].[Employees]
WHERE [Region] = NULL
This query returns no records. The reason for this is that '[Region] = NULL' evaluates to Unknown every time. Since it never evaluates to True for any rows, it returns no records.

NOTE: It has been widely misstated (even in SQL Server Books Online) that "the result of a comparison is false if one of the operands is NULL." In fact, the ANSI-92 SQL Standard states that if one of the operands is NULL, the result of the comparison is "UNKNOWN". (ANSI-92 SQL Standard) SQL Books Online has recently been updated to reflect the accurate ANSI Standard concerning NULL comparisons (See the update here: Microsoft ANSI_NULLS).

NULL Versus NULL

NULLs are not equal to other NULLs. In his article, Understanding the Difference Between "IS NULL" and "=NULL", James Travis states that a comparison to a variable initialized to NULL returns False. And it would appear so by his example:
DECLARE @val CHAR(4)
SET @val = NULL
SET ANSI_NULLS ON
If @val = NULL
PRINT 'TRUE'
ELSE
PRINT 'FALSE'
Mr. Travis' example prints 'FALSE', which indicates that the result of the comparison '@val = NULL' is False. This is not the case, however. The result of '@val = NULL' is Unknown. The IF statement will print 'TRUE' if, and only if, the result of the comparison is True; otherwise it falls through to the ELSE statement and prints 'FALSE'. For three-valued logic, we need three comparisons to figure out what the actual result of the '@val = NULL' comparison is:
SET ANSI_NULLS ON
DECLARE @val CHAR(4)
SET @val = NULL
SET ANSI_NULLS ON
If @val = NULL
PRINT 'TRUE'
ELSE IF NOT(@val = NULL)
PRINT 'FALSE'
ELSE
PRINT 'UNKNOWN'
Now we see that the result of the comparison is neither True nor False. It is the third value in our three-valued logic, Unknown. Try this statement to demonstrate that NULL is not equal to other NULLs:
SET ANSI_NULLS ON
IF NULL = NULL
PRINT 'TRUE'
ELSE IF NOT (NULL = NULL)
PRINT 'FALSE'
ELSE
PRINT 'UNKNOWN'
This statement prints 'UNKNOWN' because 'NULL = NULL' evaluates to Unknown. Since 'NULL = NULL' evaluates to Unknown, if we look back at the NOT Logic table for three-valued logic, we see that 'NOT(Unknown)' also evaluates to Unknown. This means that 'NOT(NULL = NULL)' is Unknown as well. So what do we expect when we run this statement?
SET ANSI_NULLS ON
IF NULL <> NULL
PRINT 'TRUE'
ELSE IF NOT (NULL <> NULL)
PRINT 'FALSE'
ELSE
PRINT 'UNKNOWN'
If you expect to see ‘TRUE’, guess again! ‘FALSE’? Not a chance. Remember what we said earlier – any comparisons with NULL evaluate to Unknown (neither True nor False). Since the comparisons in the IF statements evaluate to Unknown, ‘UNKNOWN’ is printed in this instance.

The same is true for any comparisons with NULL under the ANSI Standard; whether you are comparing NULL to a CHAR, INT or any other value, variable or table column.

Rule #2: In ANSI SQL, NULL is not equal to anything, even other NULLs! Comparisons with NULL always result in UNKNOWN.

NULL Variables

Variables that have been declared, but not yet initialized via SET statement default to NULL. They are treated exactly like any other NULL values. We can modify the previous queries to see this for ourselves:
SET ANSI_NULLS ON
DECLARE @MyRegion NVARCHAR(15)
SELECT * FROM [Northwind].[dbo].[Employees]
WHERE [Region] = @MyRegion
This returns no rows, just like in the previous query with '=NULL' in the WHERE clause. This has exactly the same effect as the following:
SET ANSI_NULLS ON
DECLARE @MyRegion NVARCHAR(15)
SET @MyRegion = NULL
SELECT * FROM [Northwind].[dbo].[Employees]
WHERE [Region] = @MyRegion
NOTE: You cannot put a variable in place of NULL in the IS NULL clause. The following query will *not* work:
SET ANSI_NULLS ON
DECLARE @MyRegion NVARCHAR(15)
SELECT * FROM [Northwind].[dbo].[Employees]
WHERE [Region] IS @MyRegion

ANSI Versus Microsoft

As we described above, the ANSI SQL Standard describes the result of any comparison with NULL as Unknown. So NULL = NULL, NULL <> 10 and NULL < ‘Hello’ are all Unknown.

Presumably to make the transition smoother for 3GL and 4GL programmers from other languages moving over to SQL, Microsoft implemented the SET ANSI_NULLS OFF option, which allows you to perform = and <> comparisons with NULL values. To demonstrate this in action, we can perform the following query:

SET ANSI_NULLS OFF
SELECT * FROM [Northwind].[dbo].[Employees]
WHERE [Region] = NULL
This allows you to perform basic equality comparisons to NULL; however, SQL written using this option may not be portable to other platforms, and might confuse others who use ANSI Standard NULL-handling. Also, if you try to perform this query without turning ANSI_NULLS OFF first, you will get no rows returned. The safe bet is to use SET ANSI_NULLS ON.

Rule #3: Use SET ANSI_NULLS ON, and always use ANSI Standard SQL Syntax for NULLs. Straying from the standard can cause problems including portability issues, incompatibility with existing code and databases and returning incorrect results.

NULL Math

One final point concerns math and string operations with NULLs. If you perform scalar math operations and string concatenation functions with NULL, the result is always NULL. For instance, this query returns NULL:
SELECT 1 + NULL
A numeric value plus, minus, divided by, or multiplied by NULL always equals NULL. A string concatenation with NULL equals NULL as well:
SELECT 'Joe' + NULL
So what if you want to treat NULL as a zero in a math operation? Use SQL's COALESCE() function:
SELECT 1 + COALESCE(NULL, 0)
The COALESCE() function returns the first non-NULL value in its list of values. So in the statement above, "COALESCE(NULL, 0)" returns 0. The SELECT statement above returns 1. Similarly you can use COALESCE() in string concatenations:
SELECT 'Joe' + COALESCE(NULL, '')
The COALESCE() function in this case returns a Zero-Length String, which is appended to 'Joe'. The end result is that 'Joe' is returned instead of NULL. SQL Server provides an additional function called ISNULL() which performs similarly to COALESCE(). Use the COALESCE() function (or alternatively use CASE), as it is ANSI standard syntax.

Rule #4: The ANSI Standard COALESCE() and CASE syntaxes are preferred over ISNULL() or other proprietary syntax.

Conclusions

SQL NULLs and three-valued logic can be confusing for a new SQL Database Designer; particularly if you are coming from a background in another 3GL or 4GL language that uses two-valued logic (i.e., C++, VB, etc.) Learning when and how to use NULLs in your databases, how SQL handles NULLs, and the results of comparisons and math/string operations with NULLs in SQL is very important in order to obtain consistent and optimized results.

For further information, you can visit:

What is the Best Method to Back up Data?

This being the age of internet, chat rooms, blogging and innovative hackers, their expectation never gets fulfilled. The news always leaks out or is methodically publicised by a rival or a gleeful hacker. Thereafter, insult is added to their injury as irate customers and the eager press demand explanations about every unsavoury detail of the incident. But data loss is not a problem affecting only the big players only any more. All of us deal with some amount of data and almost all of it is important to us. Albums have been replaced by .jpeg files, our music is inside the hard drive of our pc or laptop, and our emails are stored in offline folders or software like Microsoft Outlook. Students keep their study material in their machines, and a doctoral thesis is usually a file on the hard disk instead of being a thick volume bound in leather covers. It is, therefore, strange that we keep losing data because we have not taken the precaution of backing it up elsewhere. Several start-up home businesses have not seen the light of the day anymore after an initial incident of data loss. All of this underlines the importance of backup, which really cannot be overstressed.

Some Methods of Obtaining Backups

The method, or rather, the medium chosen for backing up data will depend on the volume of data to be stored, as well as the nature of the data. Some common methods are being enlisted below:

CD and Floppy: The floppy has largely gone out of use by now, due to its many limitations, small capacity and security problems. The CD is a good choice for obtaining backups, and is one of the favourite choices in both domestic and corporate spheres. It is cheap, readily available, portable and compatible with several file formats. Storing a CD and sharing information from it are also quite simple.

DVD: The DVD is a good choice for storing audio visual information. It may not be as cheap as the CD, but offers better quality, often lasts longer, and has way more space. DVD RWs can be used in such a way that literally every bit is used to store information. A DVD also has the same facilities when it comes to sharing and easy transporting. However, the DVD RW, many market observers feel, may turn out to be an intermediate technology and be replaced by something superior but very similar in function, or may evolve in such a way that the problems would get solved. It must be noted here that the constant research in this regard, and inventions like the Blue Ray disk etc. point out that we can hope for a better technology soon.

USB Devices: These are the new favourites all over the world. The greatest proof of the popularity of this technology lies in two facts. Firstly, the storage space of pen drives / flash drives/ memory sticks is constantly increasing. Secondly, their prices are plummeting downwards rapidly. Almost all kinds of files can be stored on these; they are very easy to carry, do not require a separate software or booting up of the machine to start functioning, and it is very convenient to share the data stored on them. For storing smaller music libraries, an iPod may be an option too.

External Hard Drives: For larger data storage requirements, external hard drives are excellent solutions. Arrays or stacks of hard drives are available for corporate purposes and are provided by all good hard drive manufacturers. Seagate, Maxtor, ASB, LaCie all make external hard drives of varying capacities and prices.

Online and Offline Storage Spaces: These are ‘spaces’ provided by professional firms, and are extremely secure for sensitive data storage.

Tapes and Printouts: Traditional storage should not be left out of the list. There is some information that one simply needs to see on the good old piece of paper. Tape has been in use for a long time now, and will probably continue for some time.

By: Jammesh Wallsh
http://saveav.blogspot.com/2007/09/what-is-best-method-to-back-up-data.html

Ensuring Data Protection

All of us require computers be it for personal use or work, or for some commercial purpose. For the same reason, it is important to take precautions because data is prone to leakage. The situation is most risky when you use the Internet as well.

Think about what you experience when you lose important data. You cannot even sleep properly if your data is lost. It is thus essential to have regular backups done.

Nobody wants their personal and confidential information to be disclosed over the Internet but unfortunately with the growing use of computers these days, data is no longer secure. The size of your organization or business is hardly a concern. It doesn't matter if you are using your computer at home or in office. The only concern is data protection. It is a great challenge in itself to protect confidential data. It is also important to be aware of what exactly are the reasons behind these data loss.

Various tools are available in the market these days in order to protect your valuable data. Some of these are backups, firewalls and various protection software packages for viruses.

Negligence by an employee is one of the other reasons for data leakage. Thus, it is considered therefore that employees can prevent a major portion of this data loss. If the employee is equipped with basic knowledge about computers and are honest while performing their tasks, lots of important data can be prevented from getting lost. If some strong security system is not implemented, employees generally take this for granted and work carelessly. This may mean that confidential data is lost.

Here are some methods that would help to protect your data:

Encryption: You can protect your data using a technique called encryption. In this technique, data is encrypted or is converted into some code, which can be decoded by only those who know the key or the related password. These days with the availability of so many data encryption software in the market, you can choose any one of them to ensure safe transaction of data.

Backups: Backing up your data is one of the tools that you should always use in order to avoid any sudden data loss. It is most effective in case of data loss due to a sudden power failure. If you are performing regular backups, these situations can easily be avoided. There is no specified interval during which you are expected to perform a backup. However, once in a week is the least limit, though thrice a week is normally advised to perform these backups. The best thing would be to ensure back up on a daily basis. Confidentiality of your data is the only criteria to set the limit for these backups.

Firewalls: A layered type of system is followed when it comes to security. An operating system may also serve as protector of data or else a firewall may be used. Through firewalls, nobody can access your system without your permission. This way, your data becomes much safer. It is recommended to update your computer at regular intervals to maintain security in a more consistent manner.

With this helpful information, you can ensure that your data is protected and not lost.

http://saveav.blogspot.com/2007/09/ensuring-data-protection.html