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

Kaspersky Worm.Win32.Generic False Positive

Posted by Steve Wiseman on November 12, 2009 with 3 Comments

We have been getting buried in reports that our Network Administrator product is being flagged by Kaspersky Antivirus as having the Worm.Win32.Generic virus.

As a precaution we test all of our software with 4 of the most popular anti-virus products – so we are sure this is a false positive.

In addition, we push all of the exe files through this website as a final check:

http://www.virustotal.com

The problem with this Worm.Win32.Generic is that it is not a signature based detection – it looks at the behavior of the application and makes its determination. Obviously I can see why Network Administrator looks like a virus. It can kill process, execute programs remotely, copy files over the network…all things a virus can do.

So we need your help – if you have Kaspersky, and you are getting the false postive…Please send them a report by visiting this page:

http://support.kaspersky.com/virlab/helpdesk.html

Pick “False Alarm” from the list, and tell them the program name (Network Administrator), and where to download it from (http://www.intelliadmin.com/NetworkAdministrator.exe) (Our program is too big to upload to their form).

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

Secure remote backup using remote desktop

Posted by Steve Wiseman on November 5, 2009 with 0 Comments

I have been playing around with a few ideas on how to backup a server I have that is on the other side of town.

One of the problems I have is that the Internet provider blocks VPN traffic, and most other ways I know of getting a secure connection.

The one thing I can do is use remote desktop. After some experimentation, I have been able to schedule remote backups every night using robocopy, and a remote desktop connection.

I will show you what I did to get this to work:

First, start out by properly configuring your remote desktop connection to…

Read the rest at www.networksteve.com

Filed Under: Uncategorized

Changes to the Website, and Feeds

Posted by Steve Wiseman on October 26, 2009 with 3 Comments

Hello Everyone,

For a while now this blog has had a split personality. We have been thinking about making a change to the blog for quite some time, and finally I think we have come up with a good solution that will make everyone happy.

My blog will now have its own website. It will give me a little more freedom in what I can write about, and will not be as closely tied to what is happening with IntelliAdmin, LLC.

Its new website will be: http://www.networksteve.com

The blog you are reading now will be the place where beta updates, news about new features, and general info about tools, and products developed here at IntelliAdmin, LLC

Both sites will feature an link area that will show the last few articles:

At www.networksteve.com:

And at www.intelliadmin.com:

For now, both sites will host duplicate content. From this point forward, however, each site will have its own posts and comments.

I hope you can bookmark both sites, and thanks for taking the time to read my blabber every day.

Filed Under: Blog

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

Connect to your VPN from the command line

Posted by Steve Wiseman on October 21, 2009 with 2 Comments

I was setting up an offsite backup system for our source code. I wanted to use the VPN client within windows to connect the two machines.

One of the problems with this idea is that I only wanted this connection to be active while the source code was being copied

It turns out that it is very simple to do. Once you have your VPN connection setup, take note of its name.

VPN Network Name

Then, inside of your batch file you can add this command to connect to the VPN

rasphone -d wimberlynet

Notice, that the name of my network connection was wimberlynet. You would replace that with the name of your network.

At the end of your script, you can disconnect by using this line:

rasphone -h wimberlynet

One gotcha is that you need to make sure you go into the properties of the VPN connection, and make sure prompting is disabled:

VPN Connection Options

And finally, make sure you connect to it once and save the password, and you will be able to totally automate your VPN connection.

Filed Under: Uncategorized

Hide user accounts in Windows 7

Posted by Steve Wiseman on October 14, 2009 with 11 Comments

Many times it is convenient to create a special administrator account that can be used for the task scheduler.

Unfortunately, if your Windows 7 computer is not joined to a domain, any accounts you create are shown at the start-up screen:

It would look better if you could remove this special account from the welcome screen, and only show real user accounts.

How can you remove this from the welcome screen?

Well, it happens that there is a registry key that will allow you to do this. Before I start to tell you what it is – I want to give you a word of warning:

Hide the wrong account, and you could lock yourself out forever. If you hose your system, don’t come crying to me

Ok, now that we got that out of the way, open regedit and drill down to:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
NT\CurrentVersion\Winlogon\

Under this key, you will need to create two sub keys. First create a key named “SpecialAccounts”, and under that key create another named “UserList”.

The final registry path will look like this:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
NT\CurrentVersion\Winlogon\SpecialAccounts\UserList

It is possible those keys already exist, and if they do then, hey, you get to skip a step

Next you need to create a new DWORD value under that key.

The value name is the exact username that you want to hide.

The numerical value is a 0 or a 1. If you set it to 0, then the account will be hidden. Set it to 1, and it will be shown.

You can see here that I have created a value for my SchedAccount:

After closing regedit, and switching back to the welcome screen we can see that the SchedAccount is no longer displayed:

This is a simple and fast way to hide an account, but at the same time please be very careful.

To drive home the point – look at the UAC prompt when I disabled all accounts, except a limited user account:

That YES button looks really clickable doesnt it? Yea right, now were stuck. No way of ever getting admin rights on the system again. Once you are in this state, you will need to restore from backup. So check twice before making those registry changes.

Filed Under: Backups, Registry, Windows 7

Network Administrator – Beta 4 Released

Posted by Steve Wiseman on October 8, 2009 with 4 Comments

We are right on track with our beta – Network Administrator Beta 4 has been released.

You can get a copy of the beta from here:

Network Administrator Beta 4

As I wrote last week, we were working on the remote execute engine within Network Administrator. I am pleased to say that it is complete.

As a result of that implementation we were able to add two new plugins. They are:

Change Network Settings

Switch a computer to DHCP, or update the DNS Settings to different servers

Change Network Settings

Remote Execute

This allows you to remotely execute a vbscript, batch file, MSI installer (It automatically makes it quiet for you), or command line program. This is a very powerful addition, since it gives you the ability to create a script, and push it across all the machines on your network. One other point to note about this is that this will be faster than you doing this yourself from the command line using tools like PSExec. This is because Network Administrator will spawn more than one process at a time to accomplish your task.

Remote Execute Plugin

If you missed my post last week, we promised 10 plugins by the time we release on October 30th. In addition to the two I just discussed, here is what we have created so far:

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.

One of our next plugins will allow you to change the password of a local admin user account. It is easy to change an Active Directory user account, but when an admin leaves, you still have those local account passwords floating around. This would allow you to change it in a few moments – across your entire network.

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.

Pre order your upgrade of Network Administrator 3.0 for only $99 (Includes a copy of 2.9)- Don’t wait – It will be $199 when it is released on October 30th. Click here to purchase