Powershell 学习: Show-Command

本文介绍了一种图形化的命令构建工具,它可以帮助用户通过可视化的界面来创建完整的命令,包括命令名称和参数名称等。创建完成后,用户可以选择直接运行或者复制这些命令。

该命令允许你指定你无法用对的命令名称,并以图形化的方式将命令参数名称展示出来

输入完成以后,可以直接点击Run button运行,也可以点击Copy button来拷贝该命令。

使用这种方式产生的命令, 都以完整的形式,完整的命令名称,参数名称来显示的。

 

 

 

11:47:50: Information - CPreRequisiteInstallerApp::InitializeLog(273) - * Version: 25.3.10.69 11:47:50: Information - CPreRequisiteInstallerApp::InitializeLog(275) - * Build Date: Jul 7 2025 11:47:50: Information - CPreRequisiteInstallerApp::InitializeLog(276) - * Build Time: 03:52:09 11:47:50: Information - CPreRequisiteInstallerApp::InitializeLog(277) - * Command Line: OfflineInstaller 11:47:50: Information - CPreRequisiteInstallerApp::Run(308) - Prerequisite Installation via UI is triggered. Progress dialog will show up now.. 11:47:50: Information - PreRequisiteUI::ProgressDialog(82) - PreRequsiteUI.cpp : Entry to progress dialog function 11:47:50: Information - CPreRequisiteVerification::IsDotNetInstalled(98) - Checking if .NET Framework is present with Min Release No 528040 11:47:50: Information - CPreRequisiteVerification::IsDotNetInstalled(121) - The.NET Framework requirement satisfied 11:47:50: Information - CPreRequisiteVerification::IsDotNetCoreInstalled(65) - Searching for Desktop Runtime 8.0.15, currently found 8.0.15 11:47:50: Information - CPreRequisiteVerification::IsDotNetCoreInstalled(79) - Found Desktop Runtime 8.0.15 that is greater than or equal to 8.0.15, the .net 8 requirement is satisfied 11:47:50: Information - CPreRequisiteVerification::IsRequireToInstallVCRedist(131) - Checking for installed VC Redist 11:47:50: Information - CPreRequisiteVerification::IsRequireToInstallVCRedist(136) - Found the installed VC Redist version details as 14.42.34433.00, 14.44.35208.00 11:47:50: Information - CPreRequisiteVerification::IsEdgeWebView2Installed(155) - Checking if Microsoft Webview2 Runtime is present on the system. 11:47:50: Information - CPreRequisiteVerification::IsEdgeWebView2Installed(219) - Status of Edge runtime on system : 1 11:47:50: Information - InstallationWorkerFunction(17) - Installation completed ... 11:47:52: Information - CPreRequisiteInstallerApp::ExitInstance(369) - Exit Code = 0
07-10
在这个脚本基础上优化 @echo off setlocal enabledelayedexpansion :: ---------------------------- :: 基础配置(可修改区域) :: ---------------------------- set “UV=F:\Software\keil5\core\UV4\UV4.exe” set “project_root=%~dp0Multi_project” :: 工程根目录 :: ---------------------------- :: 命令行参数处理 :: ---------------------------- if not “%~1”==“” ( set “TARGET_PROJECT=%~1” call :validate_project call :compile exit /b %errorlevel% ) :: ---------------------------- :: 自动检测所有子工程 :: ---------------------------- echo Scanning projects in: %project_root% set “project_count=0” for /d %%a in (“%project_root%*”) do ( set /a “project_count+=1” set “project_name=%%~nxa” set “project_list=!project_list! !project_name!” ) echo Found %project_count% project(s) :: ---------------------------- :: 主编译流程 :: ---------------------------- for %%a in (%project_list%) do ( set “TARGET_PROJECT=%%a” call :compile if errorlevel 1 ( echo [ERROR] Build failed for: %%a exit /b 1 ) ) exit /b 0 :: ---------------------------- :: 子程序:工程验证 :: ---------------------------- :validate_project if not exist “%project_root%%TARGET_PROJECT%” ( echo [ERROR] Project not exist: %TARGET_PROJECT% exit /b 2 ) if not exist “%project_root%%TARGET_PROJECT%%TARGET_PROJECT%_MCU.uvmpw” ( echo [ERROR] Project file missing: %TARGET_PROJECT%_MCU.uvmpw exit /b 3 ) exit /b 0 :: ---------------------------- :: 子程序:编译流程 :: ---------------------------- :compile echo. echo [INFO] Building project: %TARGET_PROJECT% :: 路径配置(自动生成带时间戳的日志文件) set “build_log=%~dp0logs%TARGET_PROJECT%%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%.log” set “uvproj_path=%project_root%%TARGET_PROJECT%%TARGET_PROJECT%_MCU.uvmpw” :: 清理并创建日志目录 if not exist “%~dp0logs” md “%~dp0logs” break > “%build_log%” :: 执行编译命令 echo Project file: %uvproj_path% “%UV%” -j0 -r “%uvproj_path%” -o “%build_log%” :: ---------------------------- :: 错误检查 :: ---------------------------- if not exist “%build_log%” ( echo [ERROR] Log file missing: %build_log% exit /b 4 ) type “%build_log%” | findstr /i /r “<Error>” “<error(s)>” “<错误>” if %errorlevel% equ 0 ( echo [ERROR] Compilation failed: %TARGET_PROJECT% exit /b 1 ) echo [SUCCESS] Build completed: %TARGET_PROJECT% exit /b 0
03-08
@echo off setlocal enabledelayedexpansion chcp 65001 >nul title ApacheBlockPerMin :: ------------------------------------------------------------ :: 运行日志(与脚本同目录 debug.log) set "debugLog=%~dp0debug.log" :: ========== 配置 ========== set "logDir=C:\xampp\apache\logs" set "threshold=10" set "scanInterval=60" set "blockList=C:\Users\Administrator\Desktop\blocked_ips.txt" :: ========================== :loop echo [%date% %time%] ===== loop ===== echo [%date% %time%] ===== loop ===== >> "%debugLog%" :: ---------- 检查管理员 ---------- net session >nul 2>&1 || ( echo [ERR] 需要以管理员身份运行 echo [%date% %time%] [ERR] 需要以管理员身份运行 >> "%debugLog%" pause exit /b 1 ) :: ---------- 确定日志文件 ---------- set "logFile=%logDir%\access.log" if exist "%logDir%\access_log.%date:~0,4%-%date:~5,2%-%date:~8,2%.log" ( set "logFile=%logDir%\access_log.%date:~0,4%-%date:~5,2%-%date:~8,2%.log" ) echo [%date% %time%] [INFO] 使用日志文件: %logFile% echo [%date% %time%] [INFO] 使用日志文件: %logFile% >> "%debugLog%" :: ---------- 生成上一分钟键(中文月份,适用于 CLF 格式) ---------- for /f %%t in ('powershell -NoLogo -NoProfile -Command ^ "$culture = New-Object System.Globalization.CultureInfo('zh-CN'); ^ (Get-Date).AddMinutes(-1).ToString(''dd/MMM/yyyy:HH:mm'', $culture)"') do ( set "minStr=%%t" ) echo [%date% %time%] [INFO] 扫描上一分钟 minStr=!minStr! echo [%date% %time%] [INFO] 扫描上一分钟 minStr=!minStr! >> "%debugLog%" :: ---------- 清空计数器 ---------- for /f "delims==" %%i in ('set found 2^>nul') do set "%%i=" :: ---------- 扫描日志 ---------- echo [%date% %time%] [DEBUG] 开始扫描日志文件: %logFile% echo [%date% %time%] [DEBUG] 开始扫描日志文件: %logFile% >> "%debugLog%" :: 用 findstr 先筛出可能的行,再用 for /f 逐行读取 findstr /r /c:"^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]* .*\[[0-9][0-9]/[A-Za-z][a-z][a-z]/[0-9][0-9][0-9][0-9]:[0-9][0-9]:[0-9][0-9] \+[0-9][0-9][0-9][0-9]\]" "%logFile%" 2>nul | for /f "tokens=1,4 delims=[]:" %%a in ('more') do ( set "ip=%%a" set "ts=%%b" set "ts=!ts:~0,11!" if /i "!ts!"=="!minStr!" ( echo [DEBUG] 匹配成功 IP=!ip! 时间=!ts! echo [%date% %time%] [DEBUG] 匹配成功 IP=!ip! 时间=!ts! >> "%debugLog%" set /a found[!ip!]+=1 ) ) echo [%date% %time%] [DEBUG] 日志扫描完成 echo [%date% %time%] [DEBUG] 日志扫描完成 >> "%debugLog%" :: 输出匹配结果用于调试 for /f "tokens=1,2 delims==" %%i in ('set found 2^>nul') do ( echo [DEBUG] IP=%%i 计数=%%j echo [%date% %time%] [DEBUG] IP=%%i 计数=%%j >> "%debugLog%" ) :: ---------- 封禁 ---------- for /f "tokens=1,2 delims==" %%i in ('set found 2^>nul') do ( set "ip=%%i" set "cnt=%%j" if !cnt! geq %threshold% ( echo [%date% %time%] [ACTION] 封禁 !ip! !cnt!/min echo [%date% %time%] [ACTION] 封禁 !ip! !cnt!/min >> "%debugLog%" netsh advfirewall firewall show rule name="Block_!ip!" | findstr /i "规则名称" >nul if errorlevel 1 ( netsh advfirewall firewall add rule name="Block_!ip!" dir=in action=block remoteip=!ip! >nul if !errorlevel! neq 0 ( echo [%date% %time%] [ERR] 添加防火墙规则失败 echo [%date% %time%] [ERR] 添加防火墙规则失败 >> "%debugLog%" ) else ( echo !ip! >> "%blockList%" schtasks /create /sc once /st 23:59 /tn "Unblock_!ip!" ^ /tr "netsh advfirewall firewall delete rule name='Block_!ip!'" /f >nul if !errorlevel! neq 0 ( echo [%date% %time%] [ERR] 创建任务计划失败 echo [%date% %time%] [ERR] 创建任务计划失败 >> "%debugLog%" ) ) ) ) ) echo [%date% %time%] [DEBUG] 封禁操作完成 echo [%date% %time%] [DEBUG] 封禁操作完成 >> "%debugLog%" timeout /t %scanInterval% /nobreak >nul goto :loop 闪退
07-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值