Solved Batch File Question

Migotop

Member
Member
Messages
70
I'm in the process of automating configuration for Windows at installation, like disabling services that are exploitable or that I just don't use. I wrote a batch file script for disabling the services, but now I would like to disable NetBIOS over TCP/IP using a batch file command. This is how to do it by hand:

wmic nicconfig get caption,index,TcpipNetbiosOptions
then, using the retrieved index number:
wmic nicconfig where index=1 call SetTcpipNetbios 2

how do I assign a variable to the resulting index number in step 1, then use that variable in the next command?
Thanks!
 

My Computer

System One

  • OS
    windows 8.1
    Computer type
    Laptop
    System Manufacturer/Model
    ASUS
    Browser
    firefox
    Antivirus
    avast
wmic nicconfig get caption,index,TcpipNetbiosOptions
set index=%1%
wmic nicconfig %1% call SetTcpipNetbios 2
 

My Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
wmic nicconfig get caption,index,TcpipNetbiosOptions
set index=%1%
wmic nicconfig %1% call SetTcpipNetbios 2

Thank You Thank You!
 

My Computer

System One

  • OS
    windows 8.1
    Computer type
    Laptop
    System Manufacturer/Model
    ASUS
    Browser
    firefox
    Antivirus
    avast
Did it work??
 

My Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
is this is a bat or cmd file??

you got comma's in one cmd - but not all

I see what you trying to do

you want to Select index 1 and then call next cmd

View attachment 59177
 

My Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
wmic nicconfig where Index=1 call SetTcpipNetbios where index=2

wmic nicconfig where Index=1 call SetTcpipNetbios index=2


Not sure of the command - new to me
 

My Computer

System One

  • OS
    Windows 3.1 > Windows 10
    Computer type
    PC/Desktop
    System Manufacturer/Model
    Dell XPS 8700
    CPU
    I7
    Memory
    24 GB
wmic nicconfig where Index=1 call SetTcpipNetbios where index=2

wmic nicconfig where Index=1 call SetTcpipNetbios index=2


Not sure of the command - new to me

I'll give it a whirl later and let you know tonight or tomorrow. Thanks!
 

My Computer

System One

  • OS
    windows 8.1
    Computer type
    Laptop
    System Manufacturer/Model
    ASUS
    Browser
    firefox
    Antivirus
    avast
So the first command (get) gives you a menu basically, and you have to pick which device or adapter you want to set, so you would need a way to either 1) disable NetBIOS for all adapters, or 2) identify the specific gateway to the script before it runs. Might just be easier to do this one by hand. Sure would be nice to do all post install configuring with one .bat. I'll keep looking around, let me know if find anything; Thanks for the help!
 

My Computer

System One

  • OS
    windows 8.1
    Computer type
    Laptop
    System Manufacturer/Model
    ASUS
    Browser
    firefox
    Antivirus
    avast
Solved

So, this is actually easy enough, I just did this:

wmic nicconfig where index=0 call SetTcpipNetbios 2
wmic nicconfig where index=1 call SetTcpipNetbios 2
wmic nicconfig where index=2 call SetTcpipNetbios 2
wmic nicconfig where index=3 call SetTcpipNetbios 2
wmic nicconfig where index=4 call SetTcpipNetbios 2
wmic nicconfig where index=5 call SetTcpipNetbios 2
wmic nicconfig where index=6 call SetTcpipNetbios 2


Not very pretty, but it gets the job done.
 

My Computer

System One

  • OS
    windows 8.1
    Computer type
    Laptop
    System Manufacturer/Model
    ASUS
    Browser
    firefox
    Antivirus
    avast
Someone who is not registered on this forum sent me this solution and wanted me to post it:

for /f "skip=1 delims=" %%A in (' wmic nicconfig get index ') do for %%B in (%%A) do (
echo wmic nicconfig where index=%%B call SetTcpipNetbios 2
)

Instruct Migotop to: "remove the "echo" to run the command"
 
Last edited:

My Computer

System One

  • OS
    Vista and Win7
    System Manufacturer/Model
    2xHP, 2xGateway, 1xDell, 1xSony
    Hard Drives
    5 SSDs and 12 HDs
Back
Top