Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Xboxer
- Posts: 25
- Joined: 27 Nov 2014 13:58
#1
Post
by Xboxer » 27 Nov 2014 14:09
I am using this below oneliner that reads the correct ssid key, but now I need a set variable, Can someone look this over
and give any suggestions. Thanks a lot for the help and Happy Thanksgiving as well.
bob
Code: Select all
@echo off
For /F "Tokens=5" %%K In ('Netsh Wlan Show Profiles') Do Netsh Wlan Show Profiles Name="%%K" Key=Clear|Find /I "Content"
pause>nul
Last edited by
Xboxer on 28 Nov 2014 20:15, edited 1 time in total.
-
Squashman
- Expert
- Posts: 4471
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 27 Nov 2014 14:35
Could you please be more specific. Show an example as well.
-
Xboxer
- Posts: 25
- Joined: 27 Nov 2014 13:58
#3
Post
by Xboxer » 27 Nov 2014 16:18
Thanks, for the reply Sorry if I was not clear enough. Rather that just reading out the result of the ssid key I want to just convert the script with a variable like so. Thanks again for the help.
Code: Select all
Do Set "PW=%%A"
Echo.
Echo Wi-Fi Key Password: %PW%
pause>nul
-
Squashman
- Expert
- Posts: 4471
- Joined: 23 Dec 2011 13:59
#4
Post
by Squashman » 27 Nov 2014 21:15
Still not understanding you. Are you saying you want to assign something from the output of NETSH to a variable?
I am not sure why you are piping the output the the FIND command. I don't see the word CONTENT in any of my NETSH output.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#6
Post
by foxidrive » 27 Nov 2014 22:25
See if this gives you the output:
Code: Select all
@echo off
For /F "Tokens=5" %%K In ('Netsh Wlan Show Profiles') Do for /f "tokens=2,*" %%L in (' Netsh Wlan Show Profiles Name^="%%K" Key^=Clear^|Find /I "Content" ') do set "Key=%%M"
echo "%key%"
pause>nul
-
Xboxer
- Posts: 25
- Joined: 27 Nov 2014 13:58
#7
Post
by Xboxer » 27 Nov 2014 22:47
foxidrive wrote:See if this gives you the output:
Code: Select all
@echo off
For /F "Tokens=5" %%K In ('Netsh Wlan Show Profiles') Do for /f "tokens=2,*" %%L in (' Netsh Wlan Show Profiles Name^="%%K" Key^=Clear^|Find /I "Content" ') do set "Key=%%M"
echo "%key%"
pause>nul
Sir You are a Genuis !! Made so slight mods to your code and now it works perfect for my project.
bob
-
Squashman
- Expert
- Posts: 4471
- Joined: 23 Dec 2011 13:59
#8
Post
by Squashman » 28 Nov 2014 09:34
I kind of figured that is what he wanted.
Next time you ask a question just say it as plainly and specific as possible. "I need the output of the second netsh command assigned to a variable just like the first netsh command".
-
Xboxer
- Posts: 25
- Joined: 27 Nov 2014 13:58
#9
Post
by Xboxer » 28 Nov 2014 20:21
Here is a snippet of code that outputs correctly with problem solved. Thanks again for the help Foxidrive!
xboxer
Code: Select all
@Echo Off
SetLocal
:: Wi-Fi NETWORK PASSWORD:
For /F "Tokens=5" %%K In ('Netsh Wlan Show Profile') Do For /F "tokens=2,*" %%L In ('Netsh Wlan Show Profile Name^="%%K" Key^=Clear^|Find /I "Content"') Do Set "Key=%%M"
:: PRINT TO DESKTO FILE:
Echo Wi-Fi Network Password%Key%>>%userprofile%\desktop\%username%.txt
Endlocal
Exit
-
Squashman
- Expert
- Posts: 4471
- Joined: 23 Dec 2011 13:59
#10
Post
by Squashman » 28 Nov 2014 21:21
You didn't even need to assign it to an environmental variable to output it to your file. You could have just used the TOKEN!!!!!!!