Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

when I'm using the netsh wlan command, a similarly output is shown.

C:\Windows\system32>netsh wlan show profiles

Profiles on interface Wireless Network Connection:

Group policy profiles (read only)
---------------------------------
    <None>

User profiles
-------------
    All User Profile     : WLAN-313131
    All User Profile     : FRITZ!Box Fon WLAN 7170

I want to write all profiles from this output into a text-file, without all information/text around it.
The output for out.txt should look like:

WLAN-313131
FRITZ!Box Fon WLAN 7170

Is that possible with a script language like batch, to split or filter information, so it fits to my requested output?

share|improve this question
    
You can output the results of the command to a text file by appending > out.txt to the command. It would look like: netsh wlan show profiles > out.txt as far as parsing the information out of there, I would write my batch file to search for the known string "All User Profile" and then have it append the characters after into an array. That array could then be used to create your file of names. I know that this isn't the programming help you are looking for, but the output of the command is a start. –  NewProgrammerJames Oct 30 '13 at 18:58
    
That was my first consideration as well, but I'm looking for a smart solution at script-level. As a last resort I could write a little c#-program that does it for me. –  MrMAG Oct 30 '13 at 19:51
    
That is what I was thinking I would do. C# has the ability to do this very easily. –  NewProgrammerJames Oct 30 '13 at 22:25
add comment

1 Answer

with netsh:

@echo off &setlocal
set "flag="
(for /f "tokens=1*delims=:" %%a in ('netsh wlan show profiles') do (
    if "%%a"=="User profiles" set flag=true
    if defined flag if "%%~b" neq "" (
        for /f "tokens=*" %%c in ("%%~b") do echo(%%c
    )
))>out.txt
type out.txt
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.