Below is my batch script Batch1.bat in usb
setlocal enabledelayedexpansion
for /f "tokens=2delims=:" %%a in ('netsh wlan show profile ^|findstr ":"') do (set "ssid=%%~a" & call :getpwd "%%ssid:~1%%")
:getpwd
set "ssid=%*"
for /f "tokens=2delims=:" %%i in ('netsh wlan show profile name^="%ssid:"=%" key^=clear ^| findstr /C:"Key Content"') do echo ssid: %ssid% pass: %%i >> c:\Wifi.txt
I am writing another batch script that uses echo to write above batch script as give below:
@echo off
echo setlocal enabledelayedexpansion >>c:\batch2.txt
echo for /f "tokens=2delims=:" %%%%a in ('netsh wlan show profile ^^^|findstr ":"') do (set "ssid=%%%%~a" ^& call :getpwd "%%%%ssid:~1%%%%") >>c:\batch2.txt
echo set "ssid=%%*" >>c:\batch2.txt
echo for /f "tokens=2delims=:" %%%%i in ('netsh wlan show profile name^^="%%ssid:"=%%" key^=clear ^^^| findstr /C:"Key Content"') do echo ssid: %%ssid%% pass: %%%%i >> c:\Wifi.txt >>c:\batch2.txt
But 5th line is not being echoed and written. Tried all kinds of escaping. Please anyone help.
echo for /f "tokens=2delims=:" %%%%i in ('netsh wlan show profile name^^="%%ssid:"=%%" key^=clear ^| findstr /C:"Key Content"') do echo ssid: %%ssid%% pass: %%%%i >> c:\Wifi.txt >>batch2.txt
pause
normally echo works but while redirecting it to file batch2.txt does'nt work
also tried ^>^> c:\Wifi.txt
But nothing working