Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9067

What Equivalent %* of Batch in PowerShell

$
0
0

Batch Script:

@echo offif not "!!"=="" setlocal enabledelayedexpansionfor /f "tokens=4*" %%a in ('dir /AD "%USERPROFILE%\" ^| find "DIR" ^| Find /v " ."') do if "%%b"=="" (set $dirs=!$dirs!"%%a" ) else (set $dirs=!$dirs!"%%a %%b" )call :getmaxlen !$dirs!echo Dirs !$dirs!echo maklen '%max%'pause :getmaxlenset var=%*for %%a in (!var!) do (    set #L=%%~a    for /L %%a in (0 1 100) do if not "!#L:~%%a,1!"=="" set len=%%a    set /a len+=1& set "$Lens=!$Lens!!len! ")for %%a in (!$Lens!) do (    if not defined max Set max=%%a    if %%a GTR !max! Set max=%%a)exit /b

PowerShell Script:

function demo {    $dirs = (gci $Home -Directory -force).Name    getmaxlen"max len $max"    pause }function getmaxlen {    $var = $dirs    #$var =???    $Script:max  = ($var | Measure -Maximum -Property Length).Maximum}demo

From Batch Script above, what is equivalent of set var=%* in PowerShell call function ?

I mean equivalent of %* in PowerShell. $var =???

So. I can use Powershell function getmaxlen every time i need.


Viewing all articles
Browse latest Browse all 9067

Trending Articles