Posts Tagged ‘windows’

Windows with two network connections: internal and external

Posted in Blog, Tech, Tutorial on May 6th, 2011 by Matt – 2 Comments

This post applies to both Windows 7 and Windows XP (and probably the server OS's as well).

At the office we have two available networks: An internal network with our servers that also has filtered internet and an external wifi network that just offers unfiltered internet.

The main issue is that, as an IT tech, I download a lot of large files that can slow down our network, so I often found myself using a laptop on our external wifi downloading items so that I don't slow internal people down.

My goal was to have two network connections on my Windows 7 PC, one wired internal connection and one a wifi external connection. I also want my internet traffic to go over my wifi connection but at the same time any have the ability to access all the internal sources.

A warning before I start: Doing this incorrectly can open a giant security hole in your network, please don't do it without the approval of your IT dept.

First, I simply hooked up both network connections and tested them both (by only plugging one in at a time and checking the internet) as fully functional.

Once both are functional you need to edit your routing table so the correct requests go over the correct network adapter.

You can do this via the command line, but I found the Nirsoft NetRouteView utility to make this whole process a whole bunch easier.

Download and extract the NetRouteView utility. Then if on Windows 7, right click the NetRouteView.exe file and select "Run as Administrator".

NetRouteView with two connections

Click the "Interface Name" column title to sort your entries by interface like above.

Depending on your network only one or two changes should be made. First, you need to remove the entry from your internal network. That entry is a "catch all". We want the catch all on the outside network and not the inside. So remove from your internal adapter and make sure its already there on your external connection.

For most people that should be it! But for me I had to add one entry to my internal network to get it to work. I wanted the whole (that means anything that has a 192 for its first number in it's IP address) to go on my internal network connection. So I added the following:

Adding a route

Adding a route

Thats it! To check that everything is going over the correct interface I added the Network Traffic gadget to my Windows 7 desktop twice (just drag it to the desktop twice from the gadget list). I made my internal connection red and my external connection green.

Network Traffic with two connections

Network Traffic with two connections

Now I can watch as I view a web page which adapter it's going out.

How to Remotely Change a Computer from a Static IP to DHCP

Posted in Blog on January 19th, 2011 by Matt – 2 Comments

We're currently migrating many computers from static IP assignments over to DHCP IP leases. Rather than walking from each computer to the next and manually changing the adapter settings I've been looking for a remote solution that I could either apply to computers one at a time or push out via group policy. Thanks to a VBScript originally written by MatthewBeattie and posted on the technet forums I now have a solution.


Changing an adapter to DHCP remotely


First you'll need the VBScript file. Copy and paste the following into Notepad. Assuming you want this to execute on both Windows 7 and Windows XP clients, the only line you need to edit is line 31, "subnets = Array("")" and change the to the network that you'd like this file to execute on.

'Script Name : EnableDHCP.vbs
'Author   : Matthew Beattie
'Created   : 29/12/10
'Description : This script enables DHCP for systems on specified subnets.
'Initialization Section  
Option Explicit  
Dim objFSO, wshShell, wshNetwork, hostName
On Error Resume Next
 Set objFSO   = CreateObject("Scripting.FileSystemObject")   
 Set wshNetwork = Wscript.CreateObject("Wscript.Network")  
 Set wshShell  = CreateObject("Wscript.Shell")  
 hostName    = wshNetwork.ComputerName
 If Err.Number <> 0 Then
 End If
On Error Goto 0
'Name    : ProcessScript -> Primary Function that controls all other script processing.  
'Parameters : None     ->  
'Return   : None     ->  
Function ProcessScript
 Dim ipAddress, macAddress, product, systems, system
 Dim subnets, subnet, network, continue
 product = ReadRegistry("HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProductName")
 systems = Array("Windows XP","Windows 7")
 subnets = Array("")
 'Ensure this script only applies to client operating systems. (Don't configure servers with DHCP!)
 Continue = False
 For Each system In systems
 If InStr(1, product, system, vbTextCompare) <> 0 Then
 continue = True
 Exit For
 End If
 If Not continue Then
 Exit Function
 End If
 'Enumerate the IP and MAC Addresses from the local system.
 If Not GetIPConfig(hostName, ipAddress, macAddress) Then
 Exit Function
 End If
 'Ensure the script continues processing only if the systems IP address is within the specified subnets.
 network = Left(ipAddress, InStrRev(ipAddress, ".")) & "0"
 continue = False
 For Each subnet In subnets
 If StrComp(subnet, network, vbTextCompare) = 0 Then
 continue = True
 Exit For
 End If
 'Ensure the script only continues processing if the systems IP address is within the specified subnets.
 If Not continue Then
 Exit Function
 End If
 'The system is within one of the specified subnets. Enable DHCP on all enabled interfaces that have static IP Addresses.
 If Not EnableDHCP Then
 Exit Function
 End If
End Function
'Name    : ReadRegistry -> Read the value of a registry key or value.
'Parameters : key     -> Name of the key (ending in "\") or value to read.
'Return   : ReadRegistry -> Value of key or value read from the local registry (blank is not found).
Function ReadRegistry(ByVal key)
 Dim result
 If StrComp (Left (key, 4), "HKU\", vbTextCompare) = 0 Then
 Key = "HKEY_USERS" & Mid (key, 4)
 End If
 On Error Resume Next
 ReadRegistry = WshShell.RegRead (key)
 If Err.Number <> 0 Then
 ReadRegistry = ""
 End If
 On Error Goto 0
End Function
'Name    : GetIPConfig -> Enumerates the IP & MAC Address of the system via WMI
'Parameters : hostName  -> String containing the hostname of the computer to enumerate the IP configuration for.
'      : ipAddress  -> Input/Output : Variable assigned to the IP Address of the system.
'Parameters : macAddress -> Input/Output : Variable assigned to the MAC Address of the system.
'Return   : GetIPConfig -> Returns True and the systems IP & MAC Address if successful otherwise returns False.
Function GetIPConfig(hostName, ipAddress, macAddress)
 Dim wmi, ipConfig, query
 GetIPConfig = False
 ipAddress  = ""
 macAddress = ""
 query    = "select * from Win32_NetworkAdapterConfiguration where IPEnabled = True"
 On Error Resume Next
 Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & hostName & "\root\cimv2")
 If Err.Number <> 0 Then
 Exit Function
 End If
 For Each ipConfig in wmi.ExecQuery(query)
 If Err.Number <> 0 Then
 Exit Function
 End If
 ipAddress = ipConfig.IPAddress(0)
 macAddress = ipConfig.MACAddress(0)
 If ipAddress <> "" And ipAddress <> "" And MACAddress <> "" Then
 Exit For
 End If
 On Error Goto 0
 GetIPConfig = True
End Function
'Name    : EnableDHCP -> enables DHCP on all interfaces that have static IP Addresses.
'Parameters : hostName  -> String containing the hostname of the system to enable DHCP on.
'Return   : EnableDHCP -> Returns True if DHCP was enabled otherwise False.
Function EnableDHCP
 Dim query, wmi, adapter, adapters, result
 EnableDHCP = False
 query   = "Select * From Win32_NetworkAdapterConfiguration Where DHCPEnabled = False And IPEnabled = True"
 On Error Resume Next
 Set wmi   = GetObject("winmgmts:\\" & hostName & "\root\cimv2")
 Set adapters = wmi.ExecQuery(query)
 For Each adapter In adapters
 result = adapter.EnableDHCP()
 If Err.Number <> 0 Then
 Exit Function
 End If
 On Error Goto 0
 EnableDHCP = True
End Function

Executing Manually on Remote Machines

For simplicity, place the previous EnableDHCP.vbs file either in your root C:\ or on a file share.

Download and install PsTools available here. Once installed launch a command prompt. Change to the PsTools directory with the following command:
cd \pstools

The following assumes your account has administrative privlidges on both the local and remote machine and you've saved the vbs file locally to C:\

Execute the file on the remote machine with the following command:
psexec \\<RemoteComputerNameOrIP> cscript \\<LocalComputerName>\C$\EnableDHCP.vbs

If you need to specify a remote administrator user use the following command:
psexec \\<RemoteComputerNameOrIP> -u <RemoteAdmin> cscript \\<LocalComputerName>\C$\EnableDHCP.vbs

The command will not execute cleanly because (obviously) your computer is going to lose its network connection to the other computer while it changes to DHCP.

You must invoke cscript to execute the command as by default .vbs files will not execute remotely.

Executing via Group Policy

(I'm not responsible if you screw up your domain)

Save the EnableDHCP.vbs to a file share location that allows everyone to read.

If you don't already have your computers segregated into Organizational Units, create a new OU and Create and link a new Group Policy to it.
Right click your domain > click New Organizational Unit > right click the OU you just created> click Create a GPO in this Domain, and Link it here. > name it something useful like "Enable DHCP" > Drag computers into the new OU

The best time to run this script, in my opinion, is going to be during computer startup. Edit the Group Policy you previously created to launch the script.
Right click the previously created Policy > Edit > expand Computer Configuration > Windows Settings > Scripts > double click Startup > click Add > click Browse > find the script > click OK a couple of times

That should do it!

Personally, because of the way we have some things set to start, I'm using a combination of psLoggedon to find computers that noone is logged into, then executing the script on those computers. Please always test on a non production computer before you start making big changes like this.

Schedule Automated Backups on Windows using SyncToy

Posted in Blog, Tech, Tutorial on June 18th, 2010 by Matt – 1 Comment

"You do have backups... right?" Thats a phrase I've asked often and rarely gotten a "yes" reply. If your computer completely died tomorrow, would you be prepared?

With USB disk drive prices falling lower and lower every day, there's no reason not to have your important documents backed up. For users of Apple's Mac OSX, the process for setting up a full backup of their computer is a simple as plugging in a USB disk and telling the prompt that, yes, you want to use the disk for backing up. Under Microsoft's Windows there's never been a simple method. As far as most users know the only way to backup is to manually copy and paste their files onto a USB drive occasionally. They usually start doing this manual backing up after a loss of some sort, then gradually let their guard down until they're no better off than before. If you're one of those users who doesn't backup, here's a solution to your backup needs.

By the end of this tutorial you will have fully automated backups of your "My Documents" folder to a USB hard drive.

A note: This backup method keeps an exact copy of your My Documents folder and all changes you make to it on an external drive. If you accidentally delete a file from your My Documents, it will be deleted off of the backup USB drive. However it will automatically put a copy of the file in your Recycle Bin should you need to recover it.

We're going to need one piece of hardware and one piece of software for this setup. The hardware will consist of a USB hard disk drive attached to your computer. The software we're going to use is Microsoft's SyncToy utility. Download it here: SyncToy from Microsoft and install it. Installing it is straight foward, hit "I Accept" a few times, check a box and then hit "Next" a few times. After you've installed it, go into your Start menu and open it.

This is the screen you're greeted with when you first run SyncToy. The way SyncToy works is you set up "pairs" of folders. A "left" folder and a "right" folder. You can then set up three different ways for those folders to backup and copy files from one folder to the other. Click "Create New Folder Pair" to set up our first backup.

The left folder is the source you want to backup. Since our goal is to backup our whole My Documents folder, our My Documents folder is what we need to select. Click Browse under the left folder side then highlight "My Documents" if your on Windows XP or your user name if your on Windows Vista or 7 and then hit "OK".

Now we need to select the "Right Folder" for where are backed up files will go to. In this case thats going to be our external hard drive. Hit Browse under the right folder side click the little plus sign or arrow next to "My Computer" then highlight your USB drive. The drive will most likely have  "E:" or "G:" name next to it. Now click the "Make New Folder" button so we have a place for all of our files to go. Give the folder a useful name like "My Documents Backup" and then hit "OK". Now hit next to move on to the next step.

This screen is where we setup how we want the folder pairs to backup and copy files from our "left folder" to our "right folder". We have three options: Synchronize, Echo and Contribute. The only one we care about for this tutorial is Echo. Echo will backup all of our files from our My Documents onto the USB drive. Select it and hit next.

The following is a description of the three backup method options. You can skip on to the next paragraph if you are just interested in getting the tutorial setup. Read on if you want to be able to use the SyncToy utility in a more advanced method.

  • Synchronize: This option will set up your folder pair so that any change you make to a file in either the left or right folder will be mirrored into the other folder. Example using this tutorial: If you add, delete or change a file off of the USB drive, it would add, delete or change it in of your My Documents.
  • Echo: This option is the traditional backup method. All file additions, deletions and changes in your left folder are mirrored over to your right folder. Any additions in your right folder will be ignored. Example: You add a file on My Documents, it gets copied to the USB drive. You change a file on the USB drive, the original from My Documents replaces it. You delete a file from the USB drive, it gets placed back from My Documents.
  • Contribute: This is exactly the same as Echo except it never deletes anything from the right folder (USB drive in our example). This may be the best backup method. If you accidentally delete a file from your My Documents, you can recover it from the USB drive since nothing is ever deleted from it. The only problem is it will eventually fill up your USB drive and you will need to clear out older files.

Name your folder pair. Give it a decent name like "My Documents Backup" and hit Finish.

Huge Success!

All finished! No you can hit the Run button to run your first backup.

To automate the backups we need to schedule them using the Task Scheduler.

Schedule SyncToy Sync Task in Windows Vista and Windows 7

  1. Click on the Start menu, then select All Programs – Accessories – System Tools – Task Scheduler.
  2. Click on Create Basic Task in the “Actions” pane on the right.
  3. In the “Create Basic Task Wizard”, type in a Name and Description. For example: My Documents Backup.
  4. Click on Next button.
  5. Choose the frequency of when do you want the task to start. Daily is a good choice.
  6. Click on Next button.
  7. Set a Start Time leave the start date alone. I would set the start time of 1am.
  8. Click on Next button.
  9. In the “Action” step, select Start a Program as the option for the task to perform.
  10. Click on Next button.
  11. Under “Program/Script”, click on Browse button and locate the SyncToyCmd.exe. It’s located in “C:\Program Files\SyncToy 2.1\SyncToyCmd.exe”
  12. In the “Add Arguments” textbox, type "-R" without the quotation marks.
  13. Click Finish!

Schedule a SyncToy Task in Windows XP

  1. Go to the Start menu, select All Programs – Accessories – System Tools – Scheduled Tasks.
  2. Select Add scheduled task to start the Scheduled Task Wizard. You will see a list of possible programs to run.
  3. Select SyncToy from that list.
  4. The wizard will next prompt you to enter how often you want to run the scheduled SyncToy. Select Daily.
  5. The next page asks when to start the task. Select a start time, I recommend 1am.
  6. The next page asks for the user name and password to run the program under. If you have one, enter your password you use to log onto Windows. Otherwise click Next.
  7. The final page contains an option to open the properties dialog when the wizard ends. Select this checkbox.
  8. In the pop-up box, go to the end of the Run textbox and add " -R" (notice the first space) without the quotation marks, after the last quotation mark already in the Run field.
  9. Click OK!

All finished!

You now have fully automated backups of your My Documents folder onto a USB disk drive. This exact same tutorial can be modified using you My Pictures folder or My Music folder instead of My Documents if all you want to backup is your pictures or music or any other folder on your computer.

Now no more worries about weather your documents, pictures and music are backed up.

Optimizing Window Layouts in a Widescreen World

Posted in Blog, Random, Tech on May 27th, 2010 by Matt – 5 Comments

Slashdot posted this link to a preview of the next KDE release. Its a nice upgrade from previous versions. Looks great.

KDE 4.5's upcoming look

Functionally this is the same window design that's been around for ages. Specifically the title bars at the top of the windows.

Title bars have been there doing nothing since since the first versions of Mac and Windows. Their original use was to help get the idea of a "windowed" interface across to early use. It's an idea that no longer needs these vestigial appendages.

Their location obviously works, as every popular operating system currently uses this layout. But in a world where 90% of monitors sold are in the 16:9, 16:10 or other wide-screen layout, its a terrible inefficient use of space. Why do we need a bar that spans the complete width of the window dedicated to (usually) just 5 words and 4 buttons? It's absurd. Some programs are taking it upon themselves to remedy this issue. Apple's Safari browser tested the idea in their beta versions, but abandoned it for the full release. It was a brilliant implementation, and I'm not sure why they didn't go with it. Just look at the efficient use of screen real estate.

Safari's Tabs on Top in the Beta.

The Windows OS can't break away from title bars. Too many corporate users with too much reliance on the old ways. However, Window's programs can ditch the bar. recently updated their UI, but they didn't displace the title bar. Their design lends itself to ditching the title bar, and I think they should. Here's my horrible mock-up.

A mock-up without the title bar.

KDE has a great opportunity to break the standard. It's users are generally technically savvy. They understand the concept of a window. They don't memorize button locations and blindly rely on them. The programs in the Linux environment adapt quickly to  change. Go for it KDE, innovate. You've got my support.

Four Official Themes for Windows XP

Posted in Random, Tech on May 7th, 2010 by Matt – Be the first to comment

Staring at the same computer screen at work day after day can drive a person batty. Unfortunately, we're stuck in XP land where I work, so theme options are limited.

Here are the 4 extra official Microsoft Windows XP themes I've been able to dig up. I've included them all in a single zip file to at the bottom of this post. Simply download the zip, extract everything to c:\windows\resources\themes then double-click on the first .theme file, Display Properties will open, hit OK, double-click on the second, hit OK, then the third, hit OK. Now under Display Properties > Appearance > Windows and buttons, you'll now have three more options. Zune, Embedded and Royale with two sub color schemes.

Royale Noir Theme:

Royale Theme:

Embedded Theme:

Zune Theme:

I'm currently running the Zune theme with Office 2007's theme set to black and Google Chrome's theme set to Grayscale:

You can download all four themes in the following zip file, installation instructions are included in the readme.txt file:

Download Royale XP Theme
Download Royale Noir XP Theme
Download Zune XP Theme
Download Embedded XP Theme