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

Network Administrator 3.0 Released

Posted by Joel Sundquist on October 30, 2009 with 1 Comments

We are proud to announce the release of Network Administrator 3.0. Thanks for all of the suggestions, and bug reports. Every one of them helped us.

Give it a spin, and download it from here:

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

(If you purchased a pre-order serial number – use this download and activate it with the serial number you received)

If your plugin has not been implemented, not to worry, we are going to keep pushing them out over the coming months and weeks.

Before that, our next step will be to finish the plugin builder. This will be a web based system that will be free for anyone to use. You will be able to build your own plugins using VBScript, or Batch files. Later, once we get that all smoothed out, we will consider adding other scripting platforms like Kix Script, and Powershell.

So far, we have a settings panel designer almost finished. It still needs the graphics for the different component types, but we will get that done. After that we will implement the logon system and plugin generator. Once that is complete we will start allowing people to beta test the service.

What can you do with Network Administrator? Well, you can pick a list of machines, and apply an action against them. Here are all of the current actions available:

Change network configuration

Want to switch 1000 hosts to DHCP? Have new DNS servers? No problem, with this plugin you can change them in a few clicks

Daylight Saving Time Update
Network Administrator 3 Daylight Saving Time Update
Easily update those older NT 4.1, Windows 2000, and XP machines to the latest DST settings without being forced to purchase a $5000 patch from microsoft.

Disable CDROM Drives
Network Administrator 3 Disable CDROM
Keep users from installing unwanted software. Disable and enable their CDROM / DVD drives with ease.

Set Excel 2007 to save in the older format
Network Administrator 3 Excel Document Set
Having a problem with users sending Excel 2007 documents to people outside your network? Reduce those help desk calls by forcing all of your Excel 2007 users to automatically save in the 2003/XP format.

Disable Floppy Drives
Network Administrator 3 Floppy Disabler
Prevent users from accessing their floppy drives and installing unwanted software.

Folder copy
Network Administrator 3 Folder Copy
Have a set of shortcuts you want to copy to everyone’s desktop? Or a configuration file you need to place on their C Drive? Use the folder copy plugin to copy files and folders to many machines in just a few clicks.

Block IE 7 Automatic Install
Network Administrator 3 IE 7 Blocker
Need to keep IE 6 on your network, and want to prevent those dreaded calls after users install IE 7? Use the IE 7 blocker to prevent the automatic install of IE 7.

Block IE 8 Automatic Install
Network Administrator 3 IE 8 Blocker
Keep IE 7 standard on your network by blocking the automatic install of IE 8

Kill Processes
Network Administrator 3 Kill Processes
This plugin can kill a process by name across your network. Got a piece of spyware that uses a common filename, but keeps randomizing a prefex? Use the wildcard feature to zap them all

Logon Disclaimer
Network Administrator 3 Logon Disclaimer
Have legal statements that need to be declared to users before they logon? Use the logon disclaimer to notify them

Manage Services
Network Administrator 3 Manage Services
Stop, Start, and modify services using the manage services plugin

Disable Offile FIles
Network Administrator 3 Offline File Disabler
Every fresh install of Windows XP has the ‘Offline Files’ feature enabled. This annoying functionality can be disabled with this plugin

Change Power Management Settings
Network Administrator 3 Power Management
Save energy by making changes to the power management settings on computers across your network

Remote Desktop Enabler
Network Administrator 3 Remote Desktop Enabler
Have remote registry access to a remote machine, but remote desktop is disabled? Remote desktop enabler can turn on remote desktop so you can get into that machine asap.

Remote Desktop Port Set
Network Administrator 3 Remote Desktop Port Set
Want to change the port Remote Desktop uses to listen for connections? Use this plugin to change the port that Remote Desktop listens on.

Remote Execute
Network Administrator 3 Remote Execute
Got an MSI file you want to install silently on 100 machines? Network Administrator can do it in a few clicks. Build batch files, or VBS files and easily execute them remotely.

Set Background Wallpaper
Network Administrator 3 Set Background Wallpaper
Have a corporate logo you want to have on everyone’s background? Use the wallpaper plugin to set it across your network. It will even take care of copying it to the remote host for you.

Set Local Administrator Password
Network Administrator 3 Set Local Administrator
Resetting the domain administrator password is easy, but what happens when an employee leaves the company and you have 50 machines with the same local administrator password? Normally, you would walk around to each one and change it. With the ‘Set Local Administrator Password’ feature you can change it across your network without even getting out of your chair.

Set VNC Password
Network Administrator 3 Set VNC Passwords
Use Tight VNC, or Real VNC on your network? Need to change the password on a 100 or 1000 machines? Network Administrator can change them all in one sweep of your network.

Reboot or Shutdown Computers
Network Administrator 3 Shutdown or Reboot
Quickly shutdown, or reboot computers. You can even set a time limit before your action takes place, and tell users why they need a reboot or shutdown.

Disable USB Flash Drives
Network Administrator 3 USB Flash Drive Disabler
Prevent access to USB flash drives, while allowing USB based keyboards, mice, and scanners.

Windows Autologon
Network Administrator 3 Windows Autologon
Set windows to automatically logon as a specific username and password.

Word Default Document Set
Network Administrator 3 Word Default Document Set
Upgrade to Office 2007, but want users to save in 2003/XP format by default? Use the default document set feature to make this change in a flash.

That is the complete list. The list will keep growing as we continue to improve and add them in.

If you have an idea of one you want added, or have an improvement you want made to a current one, then send us an email to plugins@intelliadmin.com

It won’t be too long, and you will be able to build your own!

Purchase today for only $199

Filed Under: Network Administrator

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