Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: New Line

  1. #11

    Default

    try:
    Code:
    @echo off 
    
    ::------------------------ 
    ::    Global Variables 
    ::------------------------ 
    
    setlocal enabledelayedexpansion 
    set lineA = 1 
    set lineB = 1 
    set lineC = 1 
    set computername = hostname 
    set date = date /t 
    set time = time /t 
    
    set stringcat=name 
    set stringcat=%stringcat%,User Name 
    set stringcat=%stringcat%,Device Name 
    set stringcat=%stringcat%,Serial Number 
    set stringcat=%stringcat%,Computer Model 
    set stringcat=%stringcat%,Deploy Date 
    
    
    set stringval=%name% 
    
    ::------------------------ 
    ::    User Name 
    ::------------------------ 
    
    set stringval=%stringval%,%username% 
    echo Username,%username% >> earthtabletsjamesTest.csv 
    
    ::------------------------ 
    ::    Device Name 
    ::------------------------ 
    
    set stringval=%stringval%,%computername% 
    echo Computer Name,%computername% >> earthtabletsjamesTest.csv 
    
    ::------------------------ 
    ::    Get Serial Number 
    ::------------------------ 
    
    for /f "delims=" %%A in ('wmic bios get serialnumber') do ( 
        if !lineA! equ 2 set serialNumber=%%A 
            set /a lineA+=1) 
    
    set stringval=%stringval%,%serialNumber% 
    echo Serial Number,%serialNumber% >> earthtabletsjamesTest.csv 
    
    ::------------------------ 
    ::    Get Model 
    ::------------------------ 
    
    for /f "delims=" %%A in ('wmic csproduct get name') do ( 
        if !lineB! equ 2 set modelName=%%A 
            set /a lineB+=1) 
    
    set stringval=%stringval%,%modelName% 
    echo Computer Model,%modelName% >> earthtabletsjamesTest.csv 
    
    ::------------------------ 
    ::    Deploy Date 
    ::------------------------ 
    
    set stringval=%stringval%,%date% %time% 
    echo Deploy Date,%date% %time% >> earthtabletsjamesTest.csv 
    
    ::------------------------ 
    ::    Get Mac Address 
    ::------------------------ 
    
    for /f "delims=" %%A in ('ipconfig/all ^| find "Physical Address"') do ( 
        for /f "tokens=2-7 delims=:-" %%B in ("%%A") do (  
            if "%%C" NEQ "00" (
    	  set macadress=%%B-%%C-%%D-%%E-%%F-%%G
    	  call :test
    	)
    
        )  
    )  
    
    echo %stringcat%>>c:test2.csv 
    echo %stringval%>>c:test2.csv 
    
    pause 
    
    :test
    	  echo Mac Addresses,%macadress% >> earthtabletsjamesTest.csv
    	  set stringcat=%stringcat%,Wired Mac Address
    	  set stringval=%stringval%,%macadress%
    its not perfect but if statements that set variables are special...

    EDIT: found this, at the bottom http://www.cynosurex.com/Forums/Disp..._in_Batch_File
    I dont have time to try it out yet...
    Last edited by Possimos; June 21st, 2011 at 04:13 PM.
    :)

  2. #12
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    I came across a few problems. The script is for most part working flawlessly aside from the following conditions, which only apply to getting the mac addresses (everything else is perfect).

    1. Some computers have modems, bluetooth devices and vlans that have a Mac assigned and are getting detected. I have found that "real" aka physical LAN\WLAN devices start with a "00". As shown above, however we also use a VPN that uses 00-FF. When I set NEQ 00-FF, then it prints a bunch of bogus crap and I can't get it to work correctly errrrr.

    I need to filter out any addresses that are:
    00-00-00-00-00-00
    00-FF-*-*-*-*
    and ones that don't start with "00"


    2. Need to be able to distinguish the differences between WLAN & LAN. I'm still kinda new to scripting and it's key searches. Can I use some kind of filtering to determine if a NIC is a WLAN.

    For example:

    if(description contains the following keywords (WLAN, WiFi, ABG, Wireless))
    echo Wireless Mac Address: %macAddress%

    else
    echo Wired Mac Address: %wiredMacAddress%

    Something along those lines.

    Anywho, I got my script working and printing the mac addresses, but I would still like to be able to differentiate between the WLAN & Lan as I mentioned above. I would really appreciate any help with this.

    Thanks again Possimos and everyone else.

  3. #13
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Got it all sorted. Tested on 7 machines and I'm getting the results I've been wanting. Here is the final result incase anyone is curious.

    PHP Code:
    @echo off 

    ::------------------------ 
    ::    Global 
    Variables 
    ::------------------------ 

    setlocal enabledelayedexpansion 
    set lineA
    =
    set lineB
    =
    set lineC
    =
    set lineD
    =1
    set computername 
    hostname 
    set date 
    date /
    set time 
    time /

    ::------------------------ 
    ::    
    User Name 
    ::------------------------ 

    ::echo 
    The user name is: %username
    for /
    "delims=" %%A in ('wmic /node:"%computerName%" ComputerSystem Get UserName') do ( 
        if !
    lineDequ 2 set listUser=%%
            set 
    /a lineD+=1

    echo 
    The user name is: %listUser

    ::------------------------ 
    ::    
    Device Name 
    ::------------------------ 

    echo 
    The Device Name is: %computername

    ::------------------------ 
    ::    
    Get Serial Number 
    ::------------------------ 

    for /
    "delims=" %%A in ('wmic bios get serialnumber') do ( 
        if !
    lineAequ 2 set serialNumber=%%
            set 
    /a lineA+=1

    echo 
    The serial number is: %serialNumber

    ::------------------------ 
    ::    
    Get Model 
    ::------------------------ 

    for /
    "delims=" %%A in ('wmic csproduct get name') do ( 
        if !
    lineBequ 2 set modelName=%%
            set 
    /a lineB+=1

    echo 
    The computer model is: %modelName

    ::------------------------ 
    ::    
    Deploy Date 
    ::------------------------ 

    echo 
    The date and time the device got deployed is: %date% %time

    ::------------------------ 
    ::    
    Get Mac Address 
    ::------------------------ 

    ::
    Wired
    for /"tokens=3 delims=," %%A in ('"getmac /v /fo csv | findstr Local"') do ( set wiredMac=%%)
    echo 
    Wired Mac Address: %wiredMac%

    ::
    Wireless
    for /"tokens=3 delims=," %%A in ('"getmac /v /fo csv | findstr Wireless"') do ( set wirelessMac=%%)
    echo 
    Wired Mac Address: %wirelessMac%

    ::------------------------
    ::    Print 
    Results
    ::------------------------

    echo %
    listUser%,%computername%,%serialNumber%,%modelName%,%date% %time%,%wiredMac%,%wirelessMac% >> \\earth\tablets\james\output.csv

    pause 

  4. #14

    Default

    I had a rather complex batch process a few months ago and found the solution at a DOS forum.
    Unfortunately that was on another hard drive but I think it may have been https://www.dostips.com
    I cannot access it until I sort out the security issue it has with my current Firefox browser.

    Dang, I've just noticed the date of this thread. Oops lol
    Oh well, I'm glad you've got it sorted.
    I'll still post this as you might want to keep that site handy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •