FTP download progress bar in batch file - batch-file

I wonder if there is a possibility the code below to enable a progress bar or percentage counter to check the progress of download, however alternativar not seen since the download is being executed by the FTP client.
Follows the code:
ECHO OFF
Color 17
Setlocal ENABLEDELAYEDEXPANSION
CLS
:MENU
ECHO.
ECHO ...............................................
ECHO . Selecione o numero desejado no menu abaixo .
ECHO ...............................................
ECHO.
ECHO 1 - Atualizar Frente/Retaguarda
ECHO 2 - Atualizar Rgourmet
ECHO 3 - Exit
ECHO.
SET /P M=Selecione 1, 2, ou 3 e pressione ENTER:
IF %M%==1 GOTO FRENTE
IF %M%==2 GOTO RGOURMET
IF %M%==3 GOTO SAIR
:FRENTE
# echo off
echo open 177.125.217.138>>frente.ftp
echo ****>>frente.ftp
echo ****>>frente.ftp
echo hash>>frente.ftp
echo cd atualizador>>frente.ftp
echo binary>>frente.ftp
echo get "libx12.dll">>frente.ftp
echo get "rjkmonitor.exe">>frente.ftp
echo get "rjkini.exe">>frente.ftp
echo quit>>frente.ftp
# echo off
echo off taskkill /F /IM rjkpdv.exe > NUL
echo off taskkill /F /IM libx12.dll > NUL
echo off taskkill /F /IM rjkretaguarda.exe > NUL
ftp -v -i -s:frente.ftp
if exist macro.txt (
rjkpdv.exe /a
rjkini.exe
) else (
del rjkretaguarda.exe
ren libx12.dll rjkretaguarda.exe
rjkretaguarda.exe /a
rjkini.exe
)
del frente.ftp
cls
GOTO MENU
:RGOURMET
# echo off
taskkill /F /IM rgourmet.exe
taskkill /F /IM rmt.exe
echo open 177.125.217.138>>rgourmet.ftp
echo ****>>rgourmet.ftp
echo ****>>rgourmet.ftp
echo hash>>rgourmet.ftp
echo cd atualizador>>rgourmet.ftp
echo binary>>rgourmet.ftp
echo get "rgourmet.exe">>rgourmet.ftp
echo get "rmt.exe">>rgourmet.ftp
echo get "rjkini.exe">>rgourmet.ftp
echo quit>>rgourmet.ftp
# echo off
ftp -v -i -s:rgourmet.ftp
rgourmet.exe /asgb
rjkini.exe
del rgourmet.ftp
cls
GOTO MENU
:SAIR
exit

The build-in Windows command-line FTP client (ftp.exe) cannot display progress of the transfer. All it can do, is what you already get with the hash command.
You have to use another FTP client to get percentage progress.
For example with WinSCP FTP client, you get the percentage progress by default.
winscp.com /command ^
"open ftp://rjk:password#177.125.217.138/" ^
"cd atualizador" ^
"get libx12.dll" ^
"get rjkmonitor.exe" ^
"get rjkini.exe" ^
"exit"
See a guide for converting Windows FTP script to WinSCP script.
(I'm the author of WinSCP)

Related

How do I make a batch file that opens certain programs?

cls
#ECHO OFF
title Heirloom SS Tool
:MENU
ECHO.
ECHO __________________________
ECHO| Select SS Option |
ECHO --------------------------
ECHO.
ECHO 1 -> Open Horion Folder
ECHO 2 -> Open Advanced Search Tool
ECHO 3 -> Open UserAssistView
ECHO 4 -> Open LastActivityView
ECHO 5 -> Open ProcessHacker
SET /P M=Type 1, 2, 3, 4 or 5 then press ENTER:
IF %M%==1 GOTO Horion
IF %M%==2 GOTO Search
IF %M%==3 GOTO UAV
IF %M%==4 GOTO LAV
IF %M%==5 GOTO PH
:Horion
explorer C:\Users\%USERNAME%\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\RoamingState
GOTO MENU
:Search
cd Tools\Search
start everything.exe
GOTO MENU
:UAV
cd Tools\UAV
start UserAssistView.exe
GOTO MENU
:LAV
cd Tools\LAV
start LastActivityView.exe
GOTO MENU
:PH
cd Tools\ProccessHacker
start ProcessHacker.exe
GOTO MENU
EXIT
Basically im trying to make a batch file that opens these certain files that i put in the same folder as this batch.
When i start the batch file it just opens a CMD Prompt for a second and then closes!
Can anyone help me solve this?
You need to escape special characters redirect > and pipe | using caret ^ as already mentioned to you by #Neko in a comment.
I would however rather use choice instead of set /p
cls
#echo off
title Heirloom SS Tool
:menu
echo.
echo __________________________
echo ^| Select SS Option ^|
echo --------------------------
echo.
echo 1 -^> Open Horion Folder
echo 2 -^> Open Advanced Search Tool
echo 3 -^> Open UserAssistView
echo 4 -^> Open LastActivityView
echo 5 -^> Open ProcessHacker
choice /c 12345 /M "Select: "
goto choice%errorlevel%
:choice5
echo cd Tools\ProccessHacker
echo start ProcessHacker.exe
goto menu
:choice4
echo cd Tools\LAV
echo start LastActivityView.exe
goto menu
:choice3
echo cd Tools\UAV
echo start UserAssistView.exe
goto menu
:choice2
echo cd Tools\Search
echo start everything.exe
goto menu
:choice1
echo explorer "C:\Users\%USERNAME%\AppData\Local\Packages\Microsoft.MinecraftUWP_8wekyb3d8bbwe\RoamingState"
goto menu
:choice0
exit
You can read more about choice by running choice /? from cmd

Send files to a ftp server and then check if it was really sent using .bat

I was making a .bat code to send .txt files to a specific folder on my ftp server. But I also wanted a way to check if these files were really uploaded. I searched a lot on the internet and unfortunately, I realized that it can't be done using .bat command.
So I tried using another way: The .bat will send the files and then will take it back to the folder, if the file already exists in the folder it will show a message that the file was successfully uploaded.
I did this script below, but the part of the "checking if was uploaded" is not working right.
Someone can help me?
#echo off
#setlocal enableextensions
#cd /d "%~dp0"
mode 34,12
color 0a
Ping www.google.nl -n 1 -w 1000 >nul 2>nul
if errorlevel 1 (set internet=Nao foi possivel se conectar ao servidor) else (set internet=Conectado) >nul 2>nul
echo %internet%
if "%internet%"=="No connection" goto 1
if "%internet%"=="Conected" goto 2
:1
echo No connection
echo.
echo Try later...
echo.
pause
exit
:2
( echo open ftp.xxxxxxxxxxx.com
echo xxxxxxx
echo xxxxxxx
echo ascii
echo lcd "c:\Vendas Pay&Go\files"
echo cd "Vendas Cartões Pay&Go"
echo cd "ECO"
echo mput *.txt
echo bye
)> %temp%\ftpsend.dat
ftp -i -s:%temp%/ftpsend.dat >nul 2>nul
del /f /s /q %temp%\ftpsend.dat >nul 2>nul
( echo open ftp.xxxxxxx.com
echo xxxxxxx
echo xxxxxxx
echo ascii
echo lcd "c:\Vendas Pay&Go\files"
echo cd "Vendas Cartões Pay&Go"
echo cd "ECO"
echo mget *.txt
echo bye
)> %temp%\ftpsend.dat
ftp -i -s:%temp%/ftpsend2.dat >nul 2>nul
del /f /s /q %temp%\ftpsend2.dat >nul 2>nul
if %*.txt% exist goto3
:4
echo File was not uploaded
pause
:3
echo File Uploaded.
del /s /f /q "c:\Vendas Pay&Go\files\*.txt"
If you want to conditional execution to display a message you can do something like this. The && means the previous command was successful. The || means the previous command was not successful.
(ftp -i -s:%temp%/ftpsend.dat | find /I "file successfully transferred" >nul) && (echo File Successfully Transferred) || ( echo File not transferred. Tray again later.)
Updated version based on comment below
(ftp -i -s:%temp%/ftpsend.dat | find /I "file successfully transferred" >nul) && (
echo File successfully sent.
del /f /s /q "c:\Vendas Pay&Go\files\*.txt" >nul
) || (
cls
echo File not uploaded. Try later.
)

Overwrite files of ftp server by batch

I have this script to send files to my ftp:
#echo off
#setlocal enableextensions
#cd /d "%~dp0"
color 0a
mode 34,12
title Enviar Vendas Eco
echo.
echo.
echo.
echo.
echo Sending ...
echo.
echo.
echo Wait ...
( echo open ftp.xxxxxxxxxxxxx.com
echo xxxxxxx
echo xxxxxx
echo ascii
echo prompt
echo cd "place1"
echo cd "place2"
echo lcd "%userprofile%\Desktop\test"
echo mput *.txt -overwrite
echo bye
)> %temp%\ftpsend.dat
ftp -s:%temp%/ftpsend.dat >nul 2>nul
del /f /s /q %temp%\ftpsend.dat >nul 2>nul
exit
By default, the script would must overwrite the files if already exists on .ftp. But it isn't happening.
What is wrong on my script?
When i run appears the file was suceffully transfered, but it didn't replace the file that already exists on ftp.
Look the image:

Update Currently Running Batch Script

Playing around with my Batch script again. It was brought to my attention that my update routine was not working correctly. Iteration 1 would result in the running script being deleted and not copying the new version from a folder I had selected. Iteration 2 now deletes the old script and copies the new script but with each line of code I change I end up with the currently running script closing, and the new updated script not launching.
Here's a snippet of the Update routine:
:Options
REM I'll set the variable here to what is set elsewhere in the script.
SET VERSION=Version 1.7
CLS
ECHO.
ECHO.
ECHO %VERSION%
ECHO.
ECHO.
ECHO ==================== OPTIONS =====================
ECHO.
ECHO 1. Update Script WIP
ECHO 2. Install entire script to Statup Folder
ECHO 3. Install individual items for auto-launch
ECHO 4. Install Windows Logout feature
ECHO 5. Uninstall
ECHO 6. Change Colors
ECHO 7. Changelog
ECHO.
ECHO =======PRESS 'Q' TO QUIT OR 'B' TO GO BACK========
ECHO.
SET OPTION=
SET /P OPTION=Select an Option:
IF /I '%OPTION%'=='1' GOTO Update
IF /I '%OPTION%'=='2' GOTO Install
IF /I '%OPTION%'=='3' GOTO I_Install
IF /I '%OPTION%'=='4' GOTO I_Logout
IF /I '%OPTION%'=='5' GOTO Uinstall
IF /I '%OPTION%'=='6' GOTO Colors
IF /I '%OPTION%'=='7' GOTO Changelog
IF /I '%OPTION%'=='q' GOTO quit
IF /I '%OPTION%'=='quit' GOTO quit
IF /I '%OPTION%'=='b' GOTO menu
IF /I '%OPTION%'=='back' GOTO menu
ECHO.
ECHO ============INVALID INPUT============
ECHO Please select a number
ECHO or select 'Q' or 'B'.
ECHO ======PRESS ANY KEY TO CONTINUE======
PAUSE > NUL
GOTO Options
:Update
ECHO.
IF EXIST "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\Shortcut Browser *.bat" (
GOTO Update_1
) ELSE (
ECHO You have not installed the script yet. Please install the script first.
)
PAUSE
GOTO Options
:Update_1
IF EXIST "%userprofile%\AppData\Local\Temp\Update.bat" (
GOTO Update_2
) ELSE (
REM Here the main script writes an update script to a batch file
ECHO DEL "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\Shortcut Browser *.bat" > "%userprofile%\AppData\Local\Temp\Update.bat"
REM I replaced the original file location with one on the desktop. The original location was on a network drive, location is confidential.
ECHO COPY "%userprofile\Desktop\Shortcut Browser *.bat" "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup" >> "%userprofile%\AppData\Local\Temp\Update.bat"
ECHO CALL "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\Shortcut Browser *.bat" >> "%userprofile%\AppData\Local\Temp\Update.bat"
ECHO EXIT >> "%userprofile%\AppData\Local\Temp\Update.bat"
)
GOTO Update_2
REM Here the main script calls upon the update script
:Update_2
CALL "%userprofile%\AppData\Local\Temp\Update.bat"
REM The script seems to hang here. Either both the scripts will remain open or close or a combination depending on where CALL and START were used.
PAUSE
GOTO Options
I saw elsewhere I could have used the FC command. I didn't know about it until troubleshooting this problem. I've gotten this far and I feel I'm just missing some small trick to get the new updated script to launch.
If you need any more info let me know. I think I covered everything.
#ECHO OFF
SETLOCAL
TITLE Super Script 5000
:Options
REM I'll set the variable here to what is set elsewhere in the script.
SET VERSION=Version 1.7
CLS
ECHO.
ECHO.
ECHO %VERSION%
ECHO.
ECHO.
ECHO ==================== OPTIONS =====================
ECHO.
ECHO 1. Update Script WIP
ECHO 2. Install entire script to Statup Folder
ECHO 3. Install individual items for auto-launch
ECHO 4. Install Windows Logout feature
ECHO 5. Uninstall
ECHO 6. Change Colors
ECHO 7. Changelog
ECHO.
ECHO =======PRESS 'Q' TO QUIT OR 'B' TO GO BACK========
ECHO.
SET "OPTION="
SET /P "OPTION=Select an Option: "
IF /I "%OPTION%"=="1" GOTO Update
IF /I "%OPTION%"=="2" GOTO Install
IF /I "%OPTION%"=="3" GOTO I_Install
IF /I "%OPTION%"=="4" GOTO I_Logout
IF /I "%OPTION%"=="5" GOTO Uinstall
IF /I "%OPTION%"=="6" GOTO Colors
IF /I "%OPTION%"=="7" GOTO Changelog
IF /I "%OPTION%"=="q" GOTO quit
IF /I "%OPTION%"=="quit" GOTO quit
IF /I "%OPTION%"=="b" GOTO menu
IF /I "%OPTION%"=="back" GOTO menu
ECHO.
ECHO ============INVALID INPUT============
ECHO Please select a number
ECHO or select 'Q' or 'B'.
ECHO ======PRESS ANY KEY TO CONTINUE======
PAUSE > NUL
GOTO Options
:Update
ECHO.
IF EXIST "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\Shortcut Browser *.bat" (
GOTO Update_1
) ELSE (
ECHO You have not installed the script yet. Please install the script first.
)
PAUSE
GOTO Options
:Update_1
IF EXIST "%tmp%\update.bat" (
2>NUL DEL "%tmp%\update.bat" || GOTO Options
)
SETLOCAL
FOR %%A IN (
"%appdata%\Microsoft\Windows\Start Menu\Programs\Startup\Shortcut Browser *.bat"
) DO (
SET "old_version=%%~A"
SET "old_dir=%%~dpA"
SET "old_file=%%~nxA"
)
FOR %%A IN (
"%userprofile%\Desktop\Shortcut Browser *.bat"
) DO (
SET "new_version=%%~A"
SET "new_dir=%%~dpA"
SET "new_file=%%~nxA"
)
IF NOT DEFINED old_version (
ENDLOCAL
GOTO Options
) ELSE IF NOT DEFINED new_version (
ENDLOCAL
GOTO Options
)
(
ECHO #ECHO OFF
ECHO SETLOCAL
ECHO.
ECHO ECHO Update and restarting...
ECHO ^>NUL PING localhost -n 3
ECHO.
ECHO SET "old_version=%old_version%"
ECHO SET "new_version=%new_version%"
ECHO SET "updated_version=%old_dir%\%new_file%"
ECHO.
ECHO CALL :log /clear_log
ECHO.
ECHO IF NOT EXIST "%%new_version%%" (
ECHO CALL :log ERROR: Not exist "%%new_version%%".
ECHO EXIT /B 1
ECHO ^)
ECHO.
ECHO CALL :log Move old_version to old_version.bak.
ECHO MOVE "%%old_version%%" "%%old_version%%.bak" ^|^| (
ECHO CALL :log ERROR: Move failed to backup old version.
ECHO EXIT /B 2
ECHO ^)
ECHO.
ECHO CALL :log Copy new_version to old_version.
ECHO COPY "%%new_version%%" "%%appdata%%\Microsoft\Windows\Start Menu\Programs\Startup\" ^|^| (
ECHO CALL :log ERROR: Copy failed. Restore old version.
ECHO MOVE "%%old_version%%.bak" "%%old_version%%" ^|^| (
ECHO CALL :log ERROR: Restore old version failed.
ECHO EXIT /B 3
ECHO ^)
ECHO EXIT /B 4
ECHO ^)
ECHO.
ECHO CALL :log Delete old_version.bak.
ECHO DEL "%%old_version%%.bak" ^|^| (
ECHO CALL :log WARNING: Delete backup file failed.
ECHO ^)
ECHO.
ECHO IF NOT EXIST "%%updated_version%%" (
ECHO CALL :log ERROR: Not exist: "%%updated_version%%"
ECHO EXIT /B 5
ECHO ^)
ECHO.
ECHO ENDLOCAL
ECHO.
ECHO ECHO Ready to restart updated version
ECHO PAUSE
ECHO CALL "%old_dir%\%new_file%"
ECHO EXIT /B
ECHO.
ECHO :log
ECHO SETLOCAL
ECHO SET "log=%%tmp%%\update.log"
ECHO IF /I "%%~1"=="/clear_log" TYPE NUL ^> "%%log%%" ^& EXIT /B
ECHO IF /I "%%~1"=="/delete_log" 2^>NUL DEL "%%log%%" ^& EXIT /B
ECHO SET args=%%*
ECHO IF NOT DEFINED args EXIT /B
ECHO ECHO %%*
ECHO ^>^> "%%log%%" ECHO %%*
ECHO EXIT /B
) > "%tmp%\update.bat"
ENDLOCAL
START "Super Script 5000" "cmd /c "%tmp%\update.bat""
EXIT
:Quit
Tested on a Win7 VM. The script needs to restart on update else
weird issues may occur. CMD does not like scripts changing as it
is reading and interpreting them. Even reusing the same console
using START with /B may cause key input issues.
update.bat is overwritten every update as it stores absolute paths
so each update will be different paths with the filenames changing.
Using a wildcard with CALL may not work too well otherwise.
update.bat moves the old version to a .bak file, copies the new
version and if successful, deletes the .bak file, else moves the
.bak file to the old version. This is just to ensure a current
version always exists even if the update fails.
Changed quotes in :Options label from ' to ". Quotes are not
interchangeable like some other languages. Example: "%OPTION%"
will work if contains a space though '%OPTION%' may cause error.
I notice no SETLOCAL at the top of your full script. Advise you add
it unless you have a good reason not to.
I merged labels :Update_1 and :Update_2 into one.
Perhaps adjust Ping localhost -n number if more or less time is
needed.
Look at the %tmp%\update.log if a problem happens. Though expect
the errors to show in the console as the label :log in
update.bat echoes to console and writes to the log.

Batch file autocloses after running

I am learning A LOT lately and have managed to get a basic bat file using script i have found online and mixing it all into one.
I have hit a small glitch where one of the lines now exports to a text file in the location the file is run from.
My issue now is that it autocloses after creating the text file rather than going back to the main start screen.
Can anyone help me out with this?
I have put the script that autocloses below for reference.
the final bit seems to close it (goto :eof) but if i remove that it stops exporting to the text file?
*Still to do - backup of pst files
title CMD Utility (C) Geoff Palmer Version 1.2
mode 48,40
#echo off
echo (C) Geoff Palmer Version 1.0
echo.
cls
goto start
rem ####################### START ######################
:start
echo (C) Geoff Palmer Version 1.2
echo.
mode 48,40
color 0f
#echo off
for /f "tokens=2*" %%a in ('net user "%Username%" /domain ^| find /i "Full Name"') do set DisplayName=%%b
echo %DisplayName% Welcome to the CMD utility (Beta)!!
echo What option would you like to execute?
echo.
echo NETWORKING:
echo _____________
echo 1) Ipconfig
echo 2) Reset Network
echo 3) Ping an ip address
echo 4) Trace Root
echo 5) NetStat
echo 6) Get Mac address
echo 7) Backup saved Wifi Networks
echo.
echo SYSTEM INFO:
echo ______________
echo 8) Who am I
echo 9) Uptime
echo 10) PC Info
echo 11) Performance Check
echo 12) Disk Check
echo 13) Driver Check
echo 14) Mirror Drive
echo 15) Recover Drive
echo.
echo WINDOWS TOOLS:
echo __________________
echo 16) Clear recycle bin and Temporary files
echo 17) Hard drive Defrag
echo 18) Start or End a Task
echo 19) Battery Performance
echo 20) Outlook Backup
echo.
echo Cleanup:
echo __________________
echo 21) Remove Battery Performance Log
echo 22) Remove Driver Log
echo.
echo 23) Exit
echo.
set option=
echo.
set /p option=Select One:
echo.
if "%option%"=="1" goto ipconfig
if "%option%"=="2" goto Network
if "%option%"=="3" goto ping
if "%option%"=="4" goto tracert
if "%option%"=="5" goto netstat
if "%option%"=="6" goto getmac
if "%option%"=="7" goto Wifi
if "%option%"=="8" goto whoami
if "%option%"=="9" goto uptime
if "%option%"=="10" goto pcinfo
if "%option%"=="11" goto perfmon
if "%option%"=="12" goto CHKDSK
if "%option%"=="13" goto DRIVER
if "%option%"=="14" goto MIR
if "%option%"=="15" goto recover
if "%option%"=="16" goto clearmgr
if "%option%"=="17" goto defrag
if "%option%"=="18" goto task
if "%option%"=="19" goto Power
if "%option%"=="20" goto pst
if "%option%"=="21" goto Cleanpwr
if "%option%"=="22" goto Cleandrv
if "%option%"=="23" goto Exit
echo.
ECHO “%option%” is not valid please try again
goto start
ECHO.
rem ###################### Options #####################
rem ###################### ipconfig #######################
:ipconfig
mode 70,40
cls
color 0c
echo.
ipconfig
pause
cls
goto start
rem ###################### Network #######################
:Network
mode 80,40
cls
color 0A
cls
ipconfig /release
ipconfig /renew
ipconfig /registerdns
goto start
rem ###################### ping #######################
:ping
cls
color 0b
#echo off
mode 45,2
color 0F
set /p a="Enter IP ADDRESS: "
MODE 60,15
ping %a%
echo [----------------------------------------------------------]
pause
cls
goto start
rem ###################### tracert #######################
:tracert
mode 60,5
cls
color 0b
echo Please enter web page you would like to trace?
echo [EXAMPLE] http://www.google.com
echo.
Set /p trace=
mode 75,50
echo.
echo Trace Root initiate
tracert %trace%
pause
cls
goto start
rem ###################### netstat #######################
:netstat
#echo off
color 0F
:options
mode 45,10
cls
echo MENU OPTIONS:
echo =====================
echo a All links
echo e Ethernet Statistics
echo f Displays FDQN
echo n Addresses and ports
echo =====================
echo q to quit
echo =====================
set /p input="Enter Options Here: "
if "%input%"=="a" goto:a
if "%input%"=="e" goto:e
if "%input%"=="f" goto:f
if "%input%"=="n" goto:n
if "%input%"=="q" goto:start
echo Please choose from the Options listed above!
pause
goto:options
:a
mode 80,60
netstat.exe -a
pause
goto:options
:e
mode 80,15
netstat.exe -e
pause
goto:options
:f
mode 80,25
netstat.exe -f
pause
goto:options
:n
mode 80,20
netstat.exe -n
pause
goto:options
rem ###################### getmac #######################
:getmac
mode 60,25
#echo off
cls
color 0e
echo.
arp -a
echo.
echo Have you got all the info needed?
pause
cls
goto start
rem ###################### Wifi #######################
:Wifi
mode 90,10
cls
echo This program will save all Wifi passwords on this computer to file then close.
pause
#echo off
setlocal enabledelayedexpansion
:main
title WiFiPasswordReveal v1.0b (c) Geoff Palmer
echo. >> results.txt
echo Reveal all saved WiFi passwords Batch file script v1.0b (c) Geoff Palmer >> results.txt
echo. >> results.txt
:: Get all the profiles
call :get-profiles r
:: For each profile, try to get the password
:main-next-profile
for /f "tokens=1* delims=," %%a in ("%r%") do (
call :get-profile-key "%%a" key
if "!key!" NEQ "" (
echo WiFi: [%%a] Password: [!key!] >> results.txt
)
set r=%%b
)
if "%r%" NEQ "" goto main-next-profile
echo. >> results.txt
goto :eof
::
:: Get the WiFi key of a given profile
:get-profile-key <1=profile-name> <2=out-profile-key>
setlocal
set result=
FOR /F "usebackq tokens=2 delims=:" %%a in (
`netsh wlan show profile name^="%~1" key^=clear ^| findstr /C:"Key Content"`) DO (
set result=%%a
set result=!result:~1!
)
(
endlocal
set %2=%result%
)
goto :eof
::
:: Get all network profiles (comma separated) into the result result-variable
:get-profiles <1=result-variable>
setlocal
set result=
FOR /F "usebackq tokens=2 delims=:" %%a in (
`netsh wlan show profiles ^| findstr /C:"All User Profile"`) DO (
set val=%%a
set val=!val:~1!
set result=%!val!,!result!
)
(
endlocal
set %1=%result:~0,-1%
)
goto :eof
goto start
rem ###################### whoami #######################
:whoami
mode 45,5
color 0d
whoami
pause
cls
goto start
rem ###################### uptime #######################
:uptime
mode 50,4
color 0d
systeminfo | find "System Boot Time:"
pause
cls
goto start
rem ###################### pcinfo #######################
:pcinfo
mode 80,60
cls
color 0e
systeminfo
pause
cls
goto start
rem ###################### perfmon #######################
:perfmon
mode 45,5
cls
color 0b
echo.
echo Please wait program starting!
PERFMON
pause
cls
goto start
rem ###################### CHKDSK#######################
:CHKDSK
mode 48,5
cls
echo Please enter the drive you would like to check?
echo.
Set /p DSK=
echo.
cls
echo Check disk initiate
CHKDSK %DSK%:
pause
cls
goto start
rem ###################### clearmgr#######################
:clearmgr
echo Just follow the On Screen instructions and Press OK, Press Delete and OK.
CleanMgr
echo DONE!!
pause
cls
goto start
rem ###################### defrag #######################
:defrag
echo You will need to run this program as Administrator
echo This will Defrag all volumes:
pause
defrag /C /H /V
pause
cls
goto start
rem ###################### DRIVER#######################
:DRIVER
mode 80,50
cls
echo Querying Drivers
echo Exporting to C Drive
driverquery /v /fo csv > "C:\driverlist.csv"
pause
C:\users\%username%\desktop\driverlist.csv
goto start
rem ###################### MIR #######################
:MIR
color 0c
echo Please Enter the Source DRIVE
echo.
set /p SOURCE=
echo Please Enter the Destination DRIVE
echo.
set /p DEST=
ROBOCOPY %SOURCE%: %DEST%: /MIR
pause
cls
goto start
rem ###################### recover #######################
:recover
echo Please Enter the Source file path
echo.
set /p SOURCE=
TYPE SOURCE
pause
cls
goto start
rem ###################### Power Check #######################
:Power
mode 80,10
cls
echo You will need to run this program as Administrator
echo.
echo This will save a battery report in the root hard drive
echo.
powercfg /batteryreport /output "C:\battery_report.html"
Pause
C:\battery_report.html
goto start
rem ###################### task #######################
:task
mode 40,10
cls
echo TASK KILL OR START TASK MENU
echo.
echo What option would you like to execute?
echo.
echo T) Tasklist
echo 1) Task Kill
echo 2) start task
echo 3) back
echo.
set option=
echo.
set /p option=Select One:
echo.
if "%option%"=="T" goto tasklist
if "%option%"=="1" goto taskkill
if "%option%"=="2" goto starttask
if "%option%"=="3" goto back
rem ################# tasklist ###################
:tasklist
mode 48,50
cls
echo The fowlling process are actives!
tasklist
pause
cls
goto task
rem ################# taskkill ###################
:taskkill
echo What process would you like to end?
echo.
set /p task_name= task name without .exe
taskkill /f /im %task_name%.exe
pause
cls
goto task
rem ################# starttask ###################
:starttask
echo What process would you like to start?
echo.
set /p task_name=
start %task_name%
cls
pause
goto task..
rem ################# back ###################
:back
cls
goto start
rem ###################### cleanpwr #######################
:Cleanpwr
cls
echo Removing Battery Performance Log
pause
del /f C:\battery_report.html
echo.
echo File Deleted!
pause
cls
goto start
rem ###################### cleandrv #######################
:Cleandrv
cls
echo Removing Driver List
pause
del /f C:\driverlist.csv
echo.
echo File Deleted!
pause
cls
goto start
rem ###################### PST #######################
:pst
mode 80,40
echo Format your USB stick you want to save PST files to as P
pause
cls
color 0a
robocopy "C:\users\%username%\appdata\local\Microsoft\Outlook" "P:\Backup" /mir
pause
cls
goto start
rem ###################### exit #######################
:exit
mode 45,5
cls
echo Are you sure you want to EXIT?
echo Select c to cancel or press ok to exit
set /p input="Enter Options Here: "
if "%input%"=="ok" goto:ok
if "%input%"=="c" goto:start

Resources