Send email from the command line

Posted by Steve Wiseman on November 17, 2009 with 1 Comments

Two weeks ago, I wrote about backing up a remote windows machine using Remote Desktop.

One thing lacking from this solution is email notification. How do we know if the backup job started? Or finished?

There is a free and open source tool that can be used to solve this problem, it is called blat. It consists of an executable, and a DLL.

You can find it at http://www.blat.net/

Send Mail Command Line

Download it, and extract the files to a place where your scripts run. In my case, I put it in c:\backups

To start, you will need an SMTP server that you have access to. That is probably the most difficult part of getting it to work – which means it is very easy to use.

If I just want to send a simple email that tells me a batch script has started, I could call it like this:

blat.exe -f batch@intelliadmin.com -to support@intelliadmin.com -server 192.168.1.1 -subject "Batch file started" -body "The very important batch script has started"

You have five required options to get your email to send:

-f [FROM] (This is the email address that the message will come from)
-to [TO] (This is the email address the message will be sent to)
-subject [SUBJECT] (Subject of the email. Uses quotes if you have spaces)
-body [BODY] (Body of email. Use quotes if you have spaces)
-server [SERVER] (IP Address or host name of the server)

That is for a simple message. Blat is filled with powerful options. For example, I could run a robocopy in my script, and redirect the output to a text file like this:

robocopy c:\backup \\server\c\backup >> output.txt

Then, when I send my notification I could attach the output text file to my email like this:

blat.exe -f batch@intelliadmin.com -to support@intelliadmin.com -server 192.168.1.1 -subject "Batch file started" -body "The very important batch script has completed" -attach c:\backup\output.txt

Once the command runs, the output will show up as an attachment in my inbox:

Send email cmd prompt

Like I said, it is loaded with options. Check it out, and when you do just type blat.exe -help to get the entire list of command line parameters.

Original Article from www.networksteve.com

Filed Under: BAT Files, Tools, Utility

Date and time stamp in your batch files

Posted by Steve Wiseman on November 15, 2009 with 1 Comments

There has been some activity recently in an old 2007 post I wrote about creating a date and time stamp in your batch files.

Well, the funny part was that I said ‘Date and Time’ in the subject, but I only talked about pulling out the current date.

Sue asked “What if I need both date, and time?”

Good question. What if you want to create a file that has the current date and time for each execution of the script?

In my old article I was creating zip files, using an imaginary command line based zip program. So in my article here I am going to make our goal to zip up a folder and name it:

YYYYMMDDHHMMSS_DATA.zip

If it were run today, our script should create a file by this name:

20091111143900_DATA.zip

To accomplish this, you need to use substring batch codes. If you want more detail on how these work, I explain it in the original article:

Create a date and time stamp in your batch files

To get the current time we use the %TIME% environment variable, and %DATE% for the date.

Using the substring batch codes from my old article, this is how we would pull out the year, month and day:

%date:~-4,4%%date:~-10,2%%date:~-7,2%

How about the time? That can be a little more difficult since the numbers returned from the time are not always the same length. For example, if it is 9 o’clock, it will say 9:00 – not 09:00. This will cause trouble when using the value for our filename.

Before we deal with that space, let me show you the substring codes to pull out the time:

Milliseconds: %time:~-2,2%
Seconds: %time:~-5,2%
Minutes: %time:~-8,2%
Hours: %time:~-11,2%

So naturally, if we wanted HHMMSS we could take those values above and put them side by side:

%time:~-11,2%%time:~-8,2%%time:~-5,2%

But like I said before, the hours can give you trouble because of the space. I came up with this code to pull off the space:

SET HOUR=%time:~-11,2%
Call :TRIM %HOUR%
GOTO :EOF
:TRIM
Set HOUR=%*
:EOF
REM You would use your trimmed hour right here
@echo %HOUR%

So, pulling it all together, how would we get an environment variable filled with a good date and time stamp filename?

Here is the code:
REM Get the hour first and put in an environment var

SET HOUR=%time:~-11,2%
Call :TRIM %HOUR%
GOTO :EOF
:TRIM
Set HOUR=%*
:EOF

REM Create our timestamp filename variable
SET DATESTMP=%date:~-4,4%%date:~-10,2%%date:~-7,2%%HOUR%
SET FILENAME=%DATESTMP%%time:~-8,2%%time:~-5,2%_DATA.ZIP

REM This is just an example call using our new filename
REM -=The real PKZIP program probably uses a different command line syntax
pkzip.exe c:\ImportantFolder\*.* c:\ZIPFILES\%FILENAME%

Using the code above, you can easily generate new files using the date and time in your batch script.

Original Article from www.networksteve.com

Network Administrator 3.0 Update

Posted by Steve Wiseman on November 11, 2009 with 2 Comments

It has been less than two weeks since we released Network Administrator 3.0.

One of the things we did miss in that release was new icons – we actually used the same icon as Remote Control 4

Normally, this would not be a problem, since you can easily see what program you are running in the task bar. This all changed with Windows 7

In Windows 7, there are no captions by the icons. When both programs are running side by side, it can get annoying trying to figure out which one to click:

Network Administrator Next To Remote Control

We had new icons designed for Network Administrator, and released a new version that uses them:

Network Administrator New Icon

Now when you are using these two programs together under Windows 7, it is easy to see which one to click:

Remote Control and Network Administrator Icons

You can download your update from here:

http://www.intelliadmin.com/NetworkAdministrator.exe

Change Power Save Settings Remotely

Posted by Steve Wiseman on October 23, 2009 with 10 Comments

We have been working hard on Network Administrator 3.

It was just released – You can download it from here:

http://www.intelliadmin.com/NetworkAdministrator.exe

Network Administrator allows you to make tweaks and changes to computers across your network, and in version 3 we have an extensive plugin system that allows us to add functionality quite quickly.

One of the requests we keep getting is a plugin to change power management settings. It turns out that this is actually much harder than it seems. There are different ways in each version of windows – and some of them don’t even work all the time.

We worked around the clock to work around all of the quirks and issues, and finally built a plugin that allows you to change these settings on Windows 2000, XP, 2003, Vista, 2008, and Windows 7.

Power Management Plugin

These settings are not even available with group policy, or any specific registry settings – so this is a huge time saver.

The settings for the plugin are packed with power management options:

Power Management Settings

In a few clicks you can change the power management options for multiple computers across your network.

Best of all, Network Administrator is a free tool to use on up to 3 computers at a time.

Give it a spin and let us know what you think.

Need to use Network Administrator 3.0 on more than 3 computers? Get an unlimited copy for only $199 Click here to purchase

Network Administrator – Beta 3

Posted by Steve Wiseman on September 30, 2009 with 0 Comments

Network Administrator Beta 3 has been released. If you never have used it before, Network Administrator allows you to perform actions on any number of machines across your network. You can reboot 100 computers with the press of a button, disable USB flash drives, or set Microsoft Word to save in 2003 format. These are just a few of things you can do with it.

You can get a copy of the beta from here:

Network Administrator Beta 3

If you purchase 2.9 today, you will get 3.0 free when it is released on October 27th – Best of all, you get it for 50% off as a regular reader of my blog. Just use this special link when ordering:

Purchase Today

In the 3.0 we have built a core system that supports plugins. This allows us to now add new actions quickly. Last time I spoke about the beta I promised 10 new plugins (in addition to the standard list of actions in 2.9) would be added before the final release.

So far we have added 4 of them. Here they are:

Mass Folder Copy – This plugin allows you to pick a folder on your hard drive, and copy it to many machines across your network. Perfect way to copy a set of shortcuts to everyone’s desktop.

Offline Files Disabler – Disables the annoying offline files setting in Windows XP, and 2003.

Logon Disclaimer – Allows you to set a logon disclaimer that is displayed to a user before they login.

Wallpaper Set – You can set a common background wallpaper image, and set options such as tile, stretch, and center.

All of these have been suggested by beta testers. We have had other great ones, like resetting the local admin password, or pushing out MSI files silently. We are still working on the remote execution engine, and once that is complete we will be able to implement some of those ideas. Get your suggestion in by mailing us at plugins@intelliadmin.com We cannot answer all of the emails sent, but we do read them all.

Give it a spin, and let us know what you think.

Free Tool – Suspend from the command line

Posted by Steve Wiseman on September 22, 2009 with 5 Comments

I have a system task schedule that wakes up my system at night, runs a few backup processes…and then shuts the computer down.

What I really wanted it to do was to suspend, or hibernate. That way I can get back into my computer quick when I come back in the morning.

After searching around, I found that this little VB Script command can be used to suspend a computer:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "RunDll32.exe powrprof.dll,SetSuspendState"

Unfortunately this does not work on all versions of Windows. For my task, I wanted something I could use on anything from Windows 2000, to the 64 bit version of Windows 7.

After many fruitless searches on Google, I had the IntelliAdmin team build one for me.

It is called System Suspend, and you can download it from here: SystemSuspend.exe

If you run the program with no options, it will immediately suspend the computer. There are two optional arguments you can use when calling it:

/Hibernate:[TRUE|FALSE] – Defaults to false. If you set Hibernate to true the computer will totally power off and save the state to disk. If Hibernate is set to false, then the system will go into a low power state that will allow you to resume quickly

/Force:[TRUE|FALSE]- Applications are notified of the suspend/hibernate by default. If you set the force option to true, then it will skip this step and perform the action immediately

We have tested it on Windows 2000, XP, 2003, Vista, Windows 7, and 2008 – including 64 bit versions…and it works great on all of them.

Filed Under: BAT Files, Tools, Utility, Windows

Monitor Network Traffic

Posted by Steve Wiseman on July 27, 2009 with 0 Comments

Last week I wrote about a free tool from Microsoft for synchronizing files. I asked you if you had any tools that made your life easier – my inbox was filled with suggestions.

One of the free tools that really caught my eye was Microsoft Network Monitor. I have been using Ethereal for a long time. It too is a great tool for monitoring network traffic.

Microsoft network Monitor 3.3 gives it a run for its money. Some quick points that make me like it:

It identifies processes that are generating the traffic:

Process View

It includes a ton of parsers that can pull out common protocols like HTTP, SMB, FTP, etc. These make it much easier to read what you are looking it:

Network Monitor Parsers

Easy selection of network cards to monitor:

Select Network Cards

It has an extensive filtering system to weed out packets you are not interested in:

Network Filters

In addition, it has many command line options to automate it without any interaction.

Check it out at:

Microsoft Network Monitor 3.3

Free file sync tool from Microsoft

Posted by Steve Wiseman on July 22, 2009 with 2 Comments

I had lunch last week with my good friend Brett. We were talking about synchronizing, and backing up files. I went on a long rant about how much I liked robocopy.

After I finished talking about robocopy, he told me about SyncToy from Microsoft. SyncToy? I had never heard of it.

The one drawback with robocopy is that it is command line only. Sometimes it is nice to just point and click. I never seem to be able to find a simple, but free file sync tool that has a nice GUI interface. From his description, it seemed to fit what I was looking for.

Finally, I took it for a spin today. It has the balance I was looking for between simplicity, and functionality. Best of all it is free.

Let me walk you through it.

Start out by downloading it from Microsoft’s website

When you run it for the first time, you are asked to create a new folder pair. A folder pair is the set of folders you want to sync.

SyncToy Main Screen

In my case it is a local folder, and a folder on a company file server. If you plan to do a one way copy keep in mind that the folder on your left is your source, and the one on the right is the destination.

Select Folders

Once you pick your folders, you can decided what to do with them.

SyncToy has these options:

Synchronize – New and updated files are copied both ways. Renames and deletes on either side are repeated on the other.

Echo – New and updated files are copied left to right. Renames and deletes on the left are repeated on the right.

Contribute – New and updated files are copied left to right. Renames on the left are repeated on the right. No deletions.

In my case, I want to have a backup of my code so I use “echo”. It will copy everything from my local drive to the server.

Sync Toy Action Selection

Click next, give it a name, and click finish. Now you have a new sync job waiting to be run:

SyncToy Waiting

Click run, and the synchronization begins.

SyncToy Finished

That is all there is too it! A little simpler than remembering to type all of the command line options into robocopy.

Is there a free utility that makes your life easier? Send me an email at support@intelliadmin.com so I can tell everyone else.

And if you missed it before, here is the download link from microsoft to get your free copy of SyncToy:

Download SyncToy 2.0

Change the Windows 7 Logon Background – Free Utility

Posted by Steve Wiseman on July 16, 2009 with 4 Comments

I have been playing with Windows 7 again. While reading through a few Windows 7 blogs, I came across an article that described how to change the Logon background in Windows 7.

If you have not had a chance to see Windows 7, this is what the default logon background looks like:

Very similar to the layout in Vista, but, in Windows 7 you can change it.

Microsoft has added this feature for OEMs…so in the future I would imagine the logon screen will be filled with Dell, HP, ASUS, etc.

Before I talk about our free utility, let me explain what needs to be done if you want to do this yourself without our free program.

To make the change you need to first open regedit, and create this key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background

Then once you have created that key, add a new DWORD Value named OEMBackground and set it to 1

Now, you need to place the image file (It must be a jpeg) in the following folder (You may need to create some of these folders along the path)

%windir%\oobe\info\backgrounds

The file must be named backgroundDefault.jpg – and very important – it must be under 256KB in size, or windows will ignore it.

Sound like too much trouble to change the background pic? Then you can use our free utility:

The program will take care of the registry changes…and better yet it will reduce the image size to fit into 256 KB. It makes it very easy to change the background.

Here is the download link:

W7BackgroundUpdate.exe

As always – no spyware, adware – only freeware goodness

Remote Control Beta RC2 Released

Posted by Steve Wiseman on June 5, 2009 with 4 Comments

I can’t thank everyone enough for their bug reports and suggestions. We have fixed every bug submitted, and implemented most of the feature requests.

Keep sending them to support@intelliadmin.com or write a comment in this blog entry

One of the ideas was to put the edit computer list right on the find form. Here is what it looks like:

Remote Control Beta 4 RC2

In addition, many of you complained about the command bar at the top of the viewer window. It keeps getting in the way of stuff at the top:

Remote Control Beta 4 RC2 Command Panel

Now it hides a little further into the top of the window, and you must hover over it for 1.5 seconds before it will show.

There are lots of other fixes. Here is the list:


-If you picked an action menu item, and then pressed space..it would bring the action menu back up (fixed)

-Computer names not always pulled properly from remote host (Fixed)

-Refresh menu added to action list (You must upgrade to server RC2 for this to work)

-Calling from the command line had a file not found error (Fixed)

-Command panel is pinned by default on initial client install

-The command panel when hidden more when retracting

-It takes 1.5 seconds before the command panel will show when on auto-hide mode.

-Import, Export, and Edit computers added to find window

-1/1/1900 is not a valid date error, and crashes on non-english versions of windows (Fixed)

-Problem with black areas on the screen not being updated (fixed)

-JPG now includes date and time for quick saving

For a limited time – If you purchase Remote Control 3.2 today, you will get the 4.0 upgrade for free. This will cost you less, since we will increase the price when 4.0 is released.

Now for the download links. We have an updated distribution tool:

Distribution Tool

An updated MSI file for those who want to use group policy:

Setup_beta.msi

And the beta download:

Beta Install File

One final note. The command panel will show the current build number. When testing make sure you update the server, and the client. If you are connecting to a beta 1 or older server it will say “Unknown Build Date” (Note that this info will be replaced with the remote computer name on the final release). If everything is up to beta 2, then it will show a date. Make sure you uninstall everything before you install the new beta.