You are not logged in.

#1 30 Jan 2019 02:01

NDog
Member
From: New Zealand
Registered: 31 May 2006
Posts: 121
Website

Recreate the linux loading symbol

On some text based installers under linux I have seen the 'loading animation' which is a sequence like this -\|/-\ and kind of looks a spinning circle.

I am wondering if any clever person has made this already, I guess without clearing the entire output and redrawing as that may be slow?

In the script below, I would like to see the 'loading animation' in the :loop1 part so that if a USB nic is not detected it will be spinning, so the user doesn't think it is frozen.

Any tips or similar workaround?

startnet.cmd

@echo off&cls
set _title=WDS Discover

title %_title% - initialise winPE...
wpeinit
REM start "" /min cmd

:: find mode winPE is booted into
for /f "tokens=2* delims= " %%g in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO (
	if %%h==0x1 set _mode=BIOS mode&color 3f
	if %%h==0x2 set _mode=UEFI mode&color 80
	)
set _title=%_title% (%_mode%)

title %_title% - initialise network...
wpeutil initializenetwork >nul
ipconfig /all
echo.

title %_title% - detecting NIC...
echo Detecting NIC...
echo If using a USB-LAN adaptor, may need to be reseated...
:loop1
  ipconfig /all | find "IPv4"
  if "%errorlevel%" equ "0" goto :next
  goto :loop1
:next

title %_title% - DHCP IP address...
ipconfig
:loop2
  ipconfig /all | find "IPv4" | find "169.254." >nul
  if "%errorlevel%" equ "0" goto :loop2

title %_title% - load WDS...
ipconfig /all
echo.

:: sleep required on fast machines
ping localhost -n 4 >nul

:: run WDS
%SYSTEMDRIVE%\sources\setup.exe /wds /wdsdiscover

cmd, vbs, ps, bash
autoit, python, swift

Offline

#2 30 Jan 2019 06:16

Aacini
Member
Registered: 05 Dec 2012
Posts: 149

Re: Recreate the linux loading symbol

@echo off
setlocal EnableDelayedExpansion

set "chars=/-\|"

rem Get CR character
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"

:loop

   set /P "=%chars:~0,1%!CR!" < nul
   set "chars=%chars:~1%%chars:~0,1%"

goto loop

Offline

#3 10 Feb 2019 23:28

NDog
Member
From: New Zealand
Registered: 31 May 2006
Posts: 121
Website

Re: Recreate the linux loading symbol

Thanks for the reply, however I'm not sure how to integrate this at the end of a line right now. If I get stuck I'll ask more.


cmd, vbs, ps, bash
autoit, python, swift

Offline

Board footer

Powered by