For the for a bit below and the :Trim
part (thanks to 1 or 2), delayed expansion is needed to make the variables within this batch file be expanded at execution time rather than at parse time. Usage: variables delimited by exclamation marks (!) are evaluated on execution.
This will ensure the correct behavior in this case.
echo|set /p="test text"
gives a text without newline (thanks).
for /F "tokens=2 delims=:" %%i in (SavedNetworks.temp) do (...)
gives you the second token each line, seperated by a :
(source).
SetLocal EnableDelayedExpansion
@echo|set /p="Lese die existierenden Netzwerke ein:"
netsh wlan show profile > SavedNetworks.temp
@echo|set /p="Verarbeite die eingelesenen Netzwerke (1):"
@echo off
for /F "tokens=2 delims=:" %%i in (SavedNetworks.temp) do (
call :Trim Actual %%i
netsh wlan show profile "!Actual!" key=clear >> SavedNetworks2.temp
)
@echo on
move SavedNetworks2.temp SavedNetworks.temp
@echo|set /p="Verarbeite die eingelesenen Netzwerke (2):"
findstr "SSID-Name Sicherheitsschlssel Schlsselinhalt" SavedNetworks.temp >> SavedNetworks.txt
::notepad SavedNetworks.temp
del SavedNetworks.temp
notepad SavedNetworks.txt
::pause
exit /b
:Trim
::Line below already at the top.
::SetLocal EnableDelayedExpansion
set Params=%*
for /f "tokens=1*" %%a in ("!Params!") do EndLocal & set %1=%%b
exit /b
Unfortunately, this script does not work for all languages, namely here: findstr "SSID-Name Sicherheitsschlssel Schlsselinhalt" SavedNetworks.temp >> SavedNetworks.txt
(found it here, command and output are the german version). To find the right words for your language, uncomment ::notepad SavedNetworks.temp
and put a ::
in front of the next line. Run it and replace "SSID-Name Sicherheitsschlssel Schlsselinhalt"
fittingly.