代码改变世界

Windows Batch 编程 和 Powershell 编程

2021-07-29 10:05  jetwill  阅读(23)  评论(0编辑  收藏  举报

Batch Script - Functions with Return Values

https://www.tutorialspoint.com/batch_script/batch_script_functions_with_return_values.htm

How can I check the size of a file in a Windows batch script?

https://stackoverflow.com/questions/1199645/how-can-i-check-the-size-of-a-file-in-a-windows-batch-script/1199839
::If the file name is used as a parameter to the batch file, all you need is %~z1 (1 means first parameter)
@echo off
setlocal
set file="test.cmd"
set maxbytesize=1000

FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA

if %size% LSS %maxbytesize% (
    echo.File is ^< %maxbytesize% bytes
) ELSE (
    echo.File is ^>= %maxbytesize% bytes
)

Equivalent of Unix find command on Windows

https://superuser.com/questions/401495/equivalent-of-unix-find-command-on-windows

Creating batch script to unzip a file without additional zip tools

https://stackoverflow.com/questions/21704041/creating-batch-script-to-unzip-a-file-without-additional-zip-tools/51159081

findstr exit codes/errorlevel

https://stackoverflow.com/questions/31810950/findstr-exit-codes-errorlevel

Equivalent to 'cut' on Windows

https://stackoverflow.com/questions/25066360/equivalent-to-cut-on-windows

Equivalent of (foo &>/dev/null &) in Windows Shell

https://superuser.com/questions/777198/equivalent-of-foo-dev-null-in-windows-shell#:~:text=The%20%3E%20has%20the%20same%20meaning,will%20all%20go%20to%20NUL%20.
start /B foo >NUL 2>&1

# >/dev/null     ...   >NUL

Agent 11.3.7, Windows Server 2016 and Powershell

https://community.broadcom.com/communities/community-home/digestviewer/viewthread?MID=777596