尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

第11章 命令行使用

第11章 命令行使用
📅 发布时间:2026/6/19 1:12:49

第11章:命令行使用

11.1 命令行概述

.NET Reactor 提供强大的命令行界面(CLI),支持自动化和批处理操作。

11.2 基本语法

dotNET_Reactor.Console.exe [options] -file <input> [-targetfile <output>]

11.3 常用参数

11.3.1 输入输出

# 指定输入文件
-file MyApp.exe# 指定输出文件
-targetfile MyApp.Protected.exe# 使用项目文件
-project MyProject.nrproj# 静默模式
-quiet# 详细输出
-verbose

11.3.2 保护选项

# 启用混淆
-obfuscation 1# 设置混淆级别
-obfuscation_level standard# 启用字符串加密
-stringencryption 1# 启用 NecroBit
-necrobit 1# 启用反调试
-antidebug 1# 启用防篡改
-antitampering 1

11.4 批处理脚本

11.4.1 Windows 批处理

@echo off
setlocalset REACTOR="C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe"
set INPUT_DIR=bin\Release
set OUTPUT_DIR=bin\ProtectedREM 创建输出目录
if not exist "%OUTPUT_DIR%" mkdir "%OUTPUT_DIR%"REM 保护所有 DLL 和 EXE
for %%F in ("%INPUT_DIR%\*.exe" "%INPUT_DIR%\*.dll") do (echo Protecting %%F...%REACTOR% -file "%%F" -targetfile "%OUTPUT_DIR%\%%~nxF" -quietif errorlevel 1 (echo Failed to protect %%Fexit /b 1)
)echo All files protected successfully!
endlocal

11.4.2 PowerShell 脚本

# Protect-Assemblies.ps1param([Parameter(Mandatory=$true)][string]$InputPath,[Parameter(Mandatory=$true)][string]$OutputPath,[Parameter(Mandatory=$false)][string]$ProjectFile = "",[Parameter(Mandatory=$false)][switch]$NecroBit,[Parameter(Mandatory=$false)][switch]$Verbose
)$reactorPath = "C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe"# 获取所有程序集
$assemblies = Get-ChildItem -Path $InputPath -Filter "*.exe", "*.dll"foreach ($assembly in $assemblies) {Write-Host "Protecting $($assembly.Name)..." -ForegroundColor Cyan$args = @("-file", $assembly.FullName,"-targetfile", (Join-Path $OutputPath $assembly.Name))if ($ProjectFile) {$args += @("-project", $ProjectFile)}if ($NecroBit) {$args += "-necrobit", "1"}if (-not $Verbose) {$args += "-quiet"}& $reactorPath $argsif ($LASTEXITCODE -ne 0) {Write-Error "Failed to protect $($assembly.Name)"exit 1}
}Write-Host "All assemblies protected successfully!" -ForegroundColor Green

11.5 CI/CD 集成

11.5.1 Azure DevOps

# azure-pipelines.yml
steps:
- task: PowerShell@2displayName: 'Protect Assemblies'inputs:targetType: 'filePath'filePath: 'scripts/Protect-Assemblies.ps1'arguments: >-InputPath "$(Build.BinariesDirectory)"-OutputPath "$(Build.ArtifactStagingDirectory)/protected"-ProjectFile "protection.nrproj"-NecroBit

11.5.2 GitHub Actions

# .github/workflows/protect.yml
- name: Protect with .NET Reactorrun: |$reactor = "C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe"& $reactor -file "bin\Release\MyApp.exe" `-targetfile "protected\MyApp.exe" `-project "protection.nrproj" `-quietshell: powershell

11.5.3 Jenkins Pipeline

// Jenkinsfile
stage('Protect Assemblies') {steps {bat '''"C:\\Program Files (x86)\\Eziriz\\.NET Reactor\\dotNET_Reactor.Console.exe" ^-file "bin\\Release\\MyApp.exe" ^-targetfile "protected\\MyApp.exe" ^-project "protection.nrproj" ^-quiet'''}
}

11.6 高级用法

11.6.1 条件保护

# 根据环境变量决定保护级别
if [ "$BUILD_CONFIGURATION" = "Release" ]; thenNECROBIT="-necrobit 1"
elseNECROBIT=""
fidotNET_Reactor.Console.exe \-file MyApp.exe \-obfuscation 1 \$NECROBIT \-targetfile MyApp.Protected.exe

11.6.2 并行处理

# 并行保护多个程序集
$assemblies = Get-ChildItem -Path "bin\Release" -Filter "*.dll"$assemblies | ForEach-Object -Parallel {$reactor = "C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe"& $reactor -file $_.FullName -targetfile "protected\$($_.Name)" -quiet
} -ThrottleLimit 4

11.7 错误处理

11.7.1 退出代码

0  - 成功
1  - 一般错误
2  - 文件未找到
3  - 许可证无效
4  - 配置错误
5  - 保护失败

11.7.2 日志记录

# 启用日志
dotNET_Reactor.Console.exe \-file MyApp.exe \-log protection.log \-verbose# 检查日志
if grep -q "ERROR" protection.log; thenecho "Protection failed!"exit 1
fi

11.8 本章小结

本章介绍了 .NET Reactor 的命令行使用方法,包括:

  • 基本命令语法
  • 常用参数选项
  • 批处理脚本编写
  • CI/CD 集成方案
  • 错误处理机制

掌握命令行工具可以实现自动化保护流程,提高开发效率。

相关新闻

  • 数字人配音自由化:Linly-Talker允许任意声音上传克隆
  • 基于 Python 开发的机器学习房价预测系统
  • 基于PHP的音乐网站后台管理系统设计与实现

最新新闻

  • MPC821嵌入式处理器外部信号接口深度解析与硬件设计实战
  • AI写专著高效之路:利用AI工具,轻松完成20万字专著写作!
  • 2026年近期,知名的新疆职务犯罪法律服务如何重塑司法博弈格局? - 品牌鉴赏官2026
  • 3分钟解决Windows 11臃肿问题:免费开源工具Win11Debloat终极指南
  • 反码补码学习笔记
  • ATM网络OAM机制深度解析:从AIS/RDI信元到硬件性能监控实战

日新闻

  • 5分钟掌握Python进化算法:Geatpy高性能优化工具完全指南
  • Microchip 24AA044 EEPROM选型与应用全指南:从参数解析到实战编程
  • 华为的鸿蒙到底有多牛?为什么称作遥遥领先?

周新闻

  • 3步解锁iOS设备:applera1n激活锁绕过完全指南
  • 39 2026 人工智能证书终极盘点,普通人选 AI 证书可以从这些方向入手
  • Redis 暴露公网有多危险?从端口检查到补救步骤

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号