Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I found a utility called nmap that queries an IP address and returns the (likely) operating system. In my tests it has worked perfectly. I'd like to embed it into a vbscript and call it as a function and return only the operating system version.

Sample output:

Starting Nmap 6.25 ( ) at 2013-04-25 13:30 Central Daylight Time
Initiating Ping Scan at 13:30
Scanning servername ( [4 ports]
Completed Ping Scan at 13:30, 0.28s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 13:30
Completed Parallel DNS resolution of 1 host. at 13:30, 0.02s elapsed
Initiating SYN Stealth Scan at 13:30
Scanning servername ( [1000 ports]
Discovered open port 139/tcp on
Discovered open port 3389/tcp on
Discovered open port 80/tcp on
Discovered open port 445/tcp on
Discovered open port 3306/tcp on
Discovered open port 135/tcp on
Discovered open port 1025/tcp on
Discovered open port 1066/tcp on
Discovered open port 4445/tcp on
Completed SYN Stealth Scan at 13:30, 0.40s elapsed (1000 total ports)
Initiating OS detection (try #1) against servername (
Nmap scan report for servername (
Host is up (0.014s latency).
Not shown: 991 closed ports
80/tcp   open  http
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
1025/tcp open  NFS-or-IIS
1066/tcp open  fpo-fns
3306/tcp open  mysql
3389/tcp open  ms-wbt-server
4445/tcp open  upnotifyp
Device type: general purpose
Running: Microsoft Windows 2003
OS CPE: cpe:/o:microsoft:windows_server_2003::sp1 cpe:/o:microsoft:windows_server_2003::sp2
OS details: Microsoft Windows Server 2003 SP1 or SP2
Network Distance: 7 hops
TCP Sequence Prediction: Difficulty=262 (Good luck!)
IP ID Sequence Generation: Incremental

Read data files from: I:\Scott\Utilities\nmap-6.25
OS detection performed. Please report any incorrect results at .
Nmap done: 1 IP address (1 host up) scanned in 2.30 seconds
           Raw packets sent: 1020 (45.570KB) | Rcvd: 1020 (41.434KB)
share|improve this question

This seems to work very well

Public function GetOS(ServerName)
    Set objWShell = CreateObject("WScript.Shell") 
    Set objCmd = objWShell.Exec("nmap -O -v " & ServerName) 
    strPResult = objCmd.StdOut.Readall() 
    set objCmd = nothing: Set objWShell = nothing 
    GetOS = "Unknown" 
    if InStr(strPResult,"OS details:")>0 then 
        strTemp1 = split(strPResult,"OS details: ")
        strTemp2 = split(strTemp1(1),vbCrLf)
        GetOS = strTemp2(0)
    end if
End function

wscript.echo GetOS(testserver)
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .