Windows

Scan for available IP addresses

August 28th, 2011    2 Comments

How do you connect to a device on your local network when you know a valid user name and password but the machine:

  • Is not in your DNS system so you can’t get to it using a host name
  • Has a static IP address that’s assigned on the machine itself - but you don’t know what the address is

The answer is you need to use trial and error to find and IP address that asks you for a user name and password and when you plug in the user name and password you know are valid you get a connection.

This is a whole lot quicker if the machine accepts ping requests (which are basically little “hello, anyone there?” messages fired at a computer, to which the machine answers “yup,” if it wants to, and your computer tells you how long it took to get a response).

If you don’t already have a network scanner* installed, here’s a little shell script you can run from a Windows command prompt. Fire up the command console (cmd.exe) and enter this (changing the bits in red to suit yourself):

SET fl=c:\Alistair\ipaddresses.txt & ECHO =================================================== >> %fl% & ECHO.%date% %time% >> %fl% & FOR /L %i IN (0,1,255) DO ping -n 1 192.168.0.%i | FIND /i "Reply" | FIND /i /v "unreachable" >> %fl%

In the above:

  • c:\Alistair\ipaddresses.txt is the path to the log file where I want to write the IP addresses
  • (0,1,255) means set the variable %i to 0 to start with, increment by 1 each time the FOR loop loops and stop after it reaches 255
  • 192.168.0.%i is the IP address range (in this case this starts at 192.168.0.0 and ends at 192.168.0.255)

The first FIND command finds all lines of output containing “Reply.” These get passed to the second FIND command which removes any lines that contain “unreachable.” The result is that ping output is only logged where the ping to an IP address was responded to.

The output in the log file looks something like this:

===================================================
28/08/2011  9:22:24.26
Reply from 192.168.0.1: bytes=32 time=24ms TTL=64
Reply from 192.168.0.41: bytes=32 time=82ms TTL=64
Reply from 192.168.0.42: bytes=32 time<1ms TTL=128

A variation on the script is to look for host names for the IP addresses and log these, if found. This takes much longer to run but could be useful if you need to find out what machines on your network can be pinged with their host name:

SET fl=c:\Alistair\ipaddresses.txt & ECHO =================================================== >> %fl% & ECHO.%date% %time% >> %fl% & FOR /L %i IN (0,1,255) DO ping -a -n 1 192.168.0.%i | FINDSTR /i "Pinging.*\[ Reply" | FIND /i /v "unreachable" >> %fl%

Which produces output like this:

===================================================
28/08/2011  9:22:24.26
Reply from 192.168.0.1: bytes=32 time=24ms TTL=64
Reply from 192.168.0.41: bytes=32 time=82ms TTL=64
Pinging rolumus [192.168.0.42] with 32 bytes of data:
Reply from 192.168.0.42: bytes=32 time<1ms TTL=128

In this example, just one of the machines could be reached by a host name: romulus.

Turn it into a batch file

If, for some reason, you can see yourself needing to use this script now and again you might want to save it as a batch file that you can run simply by double-clicking the file in Windows Explorer. Here’s an example of a batch file that runs the second (slower) of the scripts:

@ECHO OFF
REM Created by Alistair 28/8/2011
REM See blog post on this: http://www.itauthor.com/2011/08/28/scan-for-available-ip-addresses/
REM For more batch file commands, see: http://ss64.com/nt/
SET fl=c:\Alistair\ipaddresses.txt
ECHO Scan IP addresses for ones that accept a ping request.
ECHO The output from this batch file is logged in %fl%
ECHO Scanning ...
ECHO =================================================== >> %fl% & ECHO.%date% %time% >> %fl% & FOR /L %%i IN (0,1,255) DO ping -a -n 1 192.168.0.%%i | FINDSTR /i "Pinging.*\[ Reply" | FIND /i /v "unreachable" >> %fl% & ECHO 192.168.0.%%i
ECHO Scan completed. See log file (%fl%) for results.

Just save this as a file with a .bat file name extension (e.g. checkIPaddresses.bat) in a location that doesn’t require Administrator privileges. For example, if you want to run it from your desktop don’t save the batch file to your desktop, save it somewhere like C:\YourStuff\batchFiles\, then create a shortcut and put the shortcut on your desktop.

Network scanners

Be very careful if you’re considering installing a network scanner. There are a lot of port and IP addresses scanners out there and a lot of them are malware. They might do the job OK but they also come with viruses, so watch out. There are infected/corrupted versions of reputable scanners, so don’t assume something is OK just because you’ve read good stuff about it, unless you are completely confident you’re getting the kosher version of it.

More information

A good source of information about Windows shell commands is: http://ss64.com/nt/

Comments

  1. User Gravatar Fahim Qasim said:

    November 25th, 2011 at 7:16 am (#)

    Nice! Great information about scan for available IP Address.

  2. User Gravatar sandeep said:

    January 10th, 2012 at 6:32 pm (#)

    Good article. I am searching for what is my websites IP and DNS address. http://ezoin.com

Leave a comment

 

Adding your choice of text editor to Flare’s Open With menu

December 2nd, 2010    2 Comments

Madcap Flare has a pretty good built-in text editor for editing topic files in text-only format. I use this all the time. But sometimes it’s handy to be able to open a topic file in an external editor of your choice so that you can use the various features of that tool. My text editor of choice is Notepad++.

image

image

Until now, when I right-clicked a topic file in Flare’s Content Explorer and chose Open With, all I got, apart from the internal text editor and the internal browser, was a choice of either Firefox or Notepad (the simple Microsoft text editor):
OpenWith-before
I wanted to see Notepad++ in there. You might want to see Dreamweaver or something else. So here’s how to add programs to that menu.

Note: This procedure involves editing the Windows Registry. You need to treat the Registry with caution. Don’t go any further if you’re at all concerned about tweaking your Registry settings. You will also need to have an Administrator account. The following procedure worked for me today, using Windows 7. However, I provide no guarantees it will work for you.

  1. First, check whether Windows knows where to find the executable file.

    To do this, enter run in the search box in the Start menu and press Enter.

    In the Run dialog box, enter the name of the executable file (e.g. notepad++.exe) and click OK.

    If the application starts it means Windows knows where this application lives. This reduces the number of steps in this procedure. If Windows does not find the application, but you know it’s installed, the process is a bit more complex and you should read ahead through the rest of the instructions before deciding whether you really want to proceed.

  2. Start the Registry Editor.

    To do this, enter regedit in the search box in the Start menu and press Enter.

    If you have Windows UAC enabled (which you should have if you know what’s good for you), you’ll be asked to confirm that you want to allow the Registry Editor to make changes to your computer. Click Yes.

  3. Expand the following sections of the Registry:

    HKEY_CLASSES_ROOT > .htm

  4. Right-click the .htm folder and choose Export.

    Exporting a Registry key creates a file that you can double-click later, if things go wrong, to reinstate that part of the Registry.

  5. Give the .reg file a suitable name (preferably something that tells you which part of the Registry it’s for and the date it was created) and save it somewhere appropriate.
  6. Expand .htm > OpenWithList.
  7. Right-click the OpenWithList folder and choose New > Key.  

    qwoop-key

  8. Change the default name (New Key #1) to the next name of the executable file. In my case, for Notepad++ this was:

    notepad++.exe

  9. Now do exactly the same thing for HKEY_CLASSES_ROOT > .html 

    Remember to export the key before you make any changes.

    If there is no OpenWithList key within .html just go ahead and add one.

  10. If Windows found the application in step 1, you can close the Registry Editor, start Flare and check that there’s a new Open with option.

    OpenWith

    Note: Changes to the Registry are applied immediately. There’s no File > Save menu item and you don’t need to apply your changes. However, you do need to close and restart Flare, if it was already running, before the application is displayed in the Open with submenu.

    If everything went okay, go back and archive or delete the .reg file you exported from the Windows Registry. It’s generally best not to leave .reg files lying around in case you accidentally run them at a later date and overwrite any Registry changes that were made since you created the export file.

  11. If Windows doesn’t know where to find your application, you need to tell it. You do this with some more Registry tweaking.

    Warning: The following worked for me but I need to stress here: all messing around in the Windows Registry has a risk. I accept no responsibility for anything that might occur after you edit your Registry. Do not do this unless: you are confident you know what you’re doing in the Registry, you’ve exported any Registry keys before you make any changes, and you’re not going to hold me in any way responsible for any badness that happens after you’ve done this. You have been warned!

    So, having said that, imagine you have a program called qwoop that you want to use to edit Flare topic files. The path to the executable is D:\Alistairs Imaginary Software\Qwoop\qwoop.exe but entering just qwoop in the Run dialog box doesn’t start the application. 

  12. Go to HKEY_CLASSES_ROOT > Applications
  13. Within Applications, create the following hierarchy of keys (replacing qwoop with your own application’s name):

    qwoop.exe > shell > open > command 

    qwoop-registry-keys

    Of these, only command has any data.

  14. Double-click the Default string entry in the command key and enter the path to the .exe file (in quotation marks if the path has spaces in it), followed by “%1” – this passes the name of the file you want to edit to the application for it to open.

    qwoop-edit-string

  15. Click OK.

    You should have something like this in the Registry Editor:

    qwoop-reg-editor

    Assuming you entered qwoop.exe as the name of the key within .htm > OpenWithList and .html > OpenWithList, in the first part of this procedure, Windows now knows what to do with this, because the new keys under Applications tell it where to find qwoop.exe.

  16. Close the Registry Editor, start Flare and check that there’s a new Open with option.

    qwoop-in-Flare

Potentially similar posts

Leave a comment



UNIX on Windows (Microsoft’s little secret)

March 16th, 2010

For many years now, Microsoft has had a technology that allows you to run UNIX commands within Windows. More importantly it provides an easy-ish way to port UNIX programs onto Windows. I say easy-ish because it's not without its issues and it's not safe to assume that something you built for Solaris or RedHat Linux will run on this Windows subsystem without further work. This means thorough testing becomes a must if you develop for UNIX and deploy on Windows.

The name of this technology? It used to be called Interix, then became Services for UNIX (SFU) as they added more bits on top of Interix, and is now known as Subsystem for UNIX-based Applications (SUA). The current name is more of a mouthful, but is a more accurate name.

Microsoft don't advertise SUA. Some of us have been using it, and its predecessors, for years. But, on the whole, it's a pretty well kept little secret. And, not surprisingly, it's only available on the server versions of Windows, or the desktop versions aimed at business users and IT professionals.

So, to run SUA, you need one of the following versions of Windows:

  • Windows Server 2008
  • Windows Server 2003 R2
  • Windows 7 - Enterprise or Ultimate Edition
  • Windows Vista - Enterprise or Ultimate Edition
          

To enable and install SUA:

  1. Go to the Control Panel.
  2. Click Programs and Features.
  3. Click Turn Windows features on or off in the left panel.
  4. Select the check box for Subsystem for UNIX-based Applications.

    SUA-enable

  5. Click OK.
  6. In the start menu, click All Programs > Subsystem for UNIX-based Applications > Download Utilities for Subsystem for UNIX-based Applications.

    SUA-download

  7. Download the SUA installer from the Microsoft website.
  8. Once downloaded, double-click Utilities and SDK for UNIX-based Applications_X86.exe in your downloads folder.
  9. Step through the auto-installer.

    I'd recommend you choose the custom setup and enable the GNU Utilities and then, in the following step, select all three check boxes to allow su to root, enable setuid and enable case sensitivity.

      
Now, you can go back to the Subsystem for UNIX-based Applications start menu item and launch a Korn shell or a C shell and, within that shell, run UNIX commands:

 SUA-shell2

I know a lot of developers who don't like SUA, but personally I've always liked it. It's really handy sometimes to have UNIX commands available within Windows, and it's a great way to familiarise yourself with UNIX tools like vi.

An important resource for SUA users is the SUA Tool Warehouse:
http://www.suacommunity.com/tool_warehouse.htm

Potentially similar posts

Leave a comment



Microsoft fixes PDF creation bug

August 23rd, 2009

There's a periodic problem with creating PDFs where the application you’re using to create the PDF (e.g. Word or FrameMaker) crashes or, worse, it completes, seemingly successfully, but the resulting PDF has chunks missing from it.

The example Microsoft gives is a document with three sections in it but the PDF that you generate ends up containing Section 1 followed by Section 3.

You might have encountered this problem if you’re a FrameMaker user and assumed it was an Adobe issue. It wasn’t, it was a Windows issue.

Here's the hotfix:
http://support.microsoft.com/?id=952909

Leave a comment



Restoring Vista’s missing “Text Document” shortcut

April 9th, 2009    2 Comments

Despite all the bad press it got, I’ve always liked Vista. I actually don’t think it was any great shakes. There are no huge benefits as far as I can tell. Being able to start an application by pressing the Windows key, typing the first few letters of the application’s name and pressing Enter is great if, like me, you like to keep your hands on the keyboard rather than using the mouse. Perversely, some might say, I like UAC, and over all Vista does look nicer that XP.

But one thing that’s always irked me is the fact that, for some reason, Microsoft decided to remove the Text Document option from the right-click > New option in Windows Explorer.

text-document-option

I quite often add little text documents here and there and I always found this shortcut in XP provided a handy way of doing this. You could just right-click > New > Text Document, then double-click the file that was created and edit the document in your default text editor.

Putting this shortcut back again involves editing your Windows Registry. Not for the feint-hearted. But fortunately, someone has done this for us and created a .reg file that you can just save and then double-click to add the settings (provided you have administrative privileges for your PC).

You can get this file here:

http://www.vistax64.com/tutorials/154554-new-context-menu-restore-default-menu-items.html

Scroll down the page to the heading To Restore Text Document and click the Download button.

Follow the instructions on the page. It says you need to restart your computer. In fact you can just end the Explorer process in Task Manager and start a new Explorer process and you’ll have the shortcut.

Leave a comment



^ back to top ^

Page 1 of 1312345Older10OlderLast »