Skip to content

Commit

Permalink
添加英语翻译
Browse files Browse the repository at this point in the history
  • Loading branch information
JusterZhu committed Dec 2, 2024
1 parent 0b56ac8 commit 0afd7c5
Show file tree
Hide file tree
Showing 8 changed files with 852 additions and 1,066 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@
sidebar_position: 3
---

### Driver 驱动
### Driver

#### (1)Windows平台
#### (1) Windows Platform

##### 驱动安装
##### Driver Installation

本组件内置使用的驱动安装工具为微软自带的工具PnPutil.exe或使用setupapi.dll来实现。
The tool used for driver installation in this component is the Microsoft built-in tool PnPutil.exe or setupapi.dll.

驱动安装时需要注意的问题有两点:
There are two key points to note when installing drivers:

| 名称 | 说明 |
| ---- | ---------------------------------- |
| 安装 | 驱动证书安装,需要在驱动之前安装。 |
| 版本 | 区分x86 , x64版本。 |
| Name | Description |
| ------- | ------------------------------------------------------------ |
| Install | Driver certificate installation should occur before the driver installation. |
| Version | Differentiate between x86 and x64 versions. |

**PnPUtil实现:**
**PnPUtil Implementation:**

PnPUtil是一个命令行实用程序,它可以用来管理Windows的驱动程序商店。你可以使用它来添加、删除和列出驱动程序。
PnPUtil is a command line utility that can be used to manage the Windows driver store. You can use it to add, delete, and list drivers.

以下是如何使用PnPUtil来安装驱动程序的步骤:
Here are the steps to install drivers using PnPUtil:

1. 打开命令提示符(以管理员身份)。
1. Open Command Prompt as an administrator.

2. 导航到包含驱动程序的INF文件的目录。
2. Navigate to the directory containing the driver's INF file.

3. 运行以下命令:
3. Run the following command:

`pnputil /add-driver <INF文件名>`
`pnputil /add-driver <INF file name>`

例如,如果你的INF文件名为`mydriver.inf`,那么你应该运行`pnputil /add-driver mydriver.inf`
For example, if your INF file name is `mydriver.inf`, you should run `pnputil /add-driver mydriver.inf`.

4. PnPUtil将会添加驱动程序到驱动程序商店,并尝试为任何匹配的设备安装驱动程序。
4. PnPUtil will add the driver to the driver store and attempt to install the driver for any matching devices.

注意,PnPUtil需要管理员权限才能运行。
Note that PnPUtil requires administrator privileges to run.

在C#中,你可以使用System.Diagnostics.Process类来运行PnPUtil。以下是一个例子:
In C#, you can use the System.Diagnostics.Process class to run PnPUtil. Here is an example:

```c#
using System.Diagnostics;
Expand All @@ -51,25 +51,23 @@ public class Program
Process process = new Process();
process.StartInfo.FileName = "pnputil.exe";
process.StartInfo.Arguments = "/add-driver " + infPath;
process.StartInfo.Verb = "runas"; // 运行为管理员
process.StartInfo.Verb = "runas"; // Run as administrator
process.Start();

process.WaitForExit();
}
}
```



**setupapi.dll实现:**
**setupapi.dll Implementation:**

```c#
using System;
using System.Runtime.InteropServices;

public class Program
{
// 定义 SetupCopyOEMInf 函数的 P/Invoke 签名
// Define the P/Invoke signature for the SetupCopyOEMInf function
[DllImport("setupapi.dll", EntryPoint = "SetupCopyOEMInf", SetLastError = true)]
public static extern bool SetupCopyOEMInf(
string SourceInfFileName,
Expand All @@ -95,28 +93,24 @@ public class Program
}
```

##### Driver Certificate

This component uses Windows certificate management tools (CertMgr.exe) or the X509Store class in the .NET framework.

##### 驱动证书

本组件内置使用Windows的证书管理工具(CertMgr.exe)或者使用.NET框架中的X509Store类来实现。

**CertMgr.exe实现:**
**CertMgr.exe Implementation:**

`CertMgr.exe` 是一个命令行工具,它是微软的.NET Framework的一部分。你可以在.NET Framework的安装目录中找到它。
`CertMgr.exe` is a command line tool that is part of the Microsoft .NET Framework. You can find it in the .NET Framework installation directory.

对于大多数系统,它的位置通常是在以下目录之一:
For most systems, it is typically located in one of the following directories:

- `C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin`
- `C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bin`

如果你找不到它,你可以使用Windows的搜索功能来搜索`CertMgr.exe`
If you cannot find it, you can use Windows search to locate `CertMgr.exe`.

注意,`CertMgr.exe`是一个命令行工具,你需要在命令提示符或PowerShell中运行它。你也可以在你的C#代码中使用`System.Diagnostics.Process.Start()`方法来调用它。
Note that `CertMgr.exe` is a command line tool and must be run in Command Prompt or PowerShell. You can also call it in your C# code using the `System.Diagnostics.Process.Start()` method.



**X509Store实现:**
**X509Store Implementation:**

```c#
using System;
Expand All @@ -128,19 +122,18 @@ public class Example
{
string CertificatePath = "Path to your certificate file";

// 创建一个新的X509证书实例
// Create a new X509 certificate instance
X509Certificate2 certificate = new X509Certificate2(CertificatePath);

// 打开当前用户的个人证书存储区
// Open the current user's personal certificate store
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);

// 将新证书添加到存储区
// Add the new certificate to the store
store.Open(OpenFlags.ReadWrite);
store.Add(certificate);

store.Close();
}
}

```

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
sidebar_position: 4
---

### Dump 转储文件
### Dump Files

在自动升级的过程中如果更新失败,或程序更新完成之后运行崩溃都可以使用ProcDump工具辅助导出dump文件。ProcDump 是一个命令行实用工具,其主要用途是监视应用程序的 CPU 峰值,并在出现峰值期间生成故障转储,管理员或开发人员可以使用这些转储来确定出现峰值的原因。 ProcDump 还支持挂起窗口监视(使用与 Windows 和任务管理器使用的窗口挂起相同的定义)、未处理的异常监视,并且可以根据系统性能计数器的值生成转储。 它还可用作可嵌入到其他脚本中的常规进程转储实用工具。
During the process of automatic updates, if an update fails or if the program crashes after the update, you can use the ProcDump tool to help export dump files. ProcDump is a command-line utility primarily used to monitor an application's CPU spikes and generate crash dumps during these spikes. Administrators or developers can use these dumps to determine the cause of the spikes. ProcDump also supports hung window monitoring (using the same definition as Windows and Task Manager), unhandled exception monitoring, and can generate dumps based on system performance counter values. It can also be used as a general-purpose process dump utility that can be embedded into other scripts.

##### (1)Windows平台
##### (1) Windows Platform

C#实现调用:
C# Implementation for Calling ProcDump:

```c#
using System;
Expand All @@ -19,7 +19,7 @@ public class Program
public static void Main()
{
var procDumpPath = @"C:\Path\To\procdump.exe";
var processId = 1234; // 您要转储的进程的ID
var processId = 1234; // The ID of the process you want to dump
var dumpFilePath = @"C:\Path\To\dumpfile.dmp";

var startInfo = new ProcessStartInfo
Expand All @@ -45,8 +45,6 @@ public class Program
}
```



参考资料:
References:

- https://learn.microsoft.com/zh-cn/sysinternals/downloads/procdump
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
sidebar_position: 2
---

### File occupancy 文件占用
### File Occupancy

#### (1)Windows平台
#### (1) Windows Platform

虽然在自动升级时会关闭应用程序,如果出现特殊情况出现文件占用通常是进程还在运行导致的。这时候可以使用微软官方提供的handle.exe检测工具来查看指定目录下是否有进程在运行"handle.exe"是一款由微软提供的命令行工具,可以用来显示哪些进程打开了哪些文件。在C#中调用handle.exe,我们可以使用`System.Diagnostics.Process`类,如果检测到则会返回该目录下正在运行的进程列表。
Even though applications are closed during automatic upgrades, file occupancy can occur if processes are still running due to special circumstances. In such cases, you can use Microsoft's handle.exe tool to check if there are any processes running in a specified directory. "handle.exe" is a command-line tool provided by Microsoft that displays which processes have opened specific files. In C#, you can invoke handle.exe using the `System.Diagnostics.Process` class. If a process is detected, it will return a list of processes running in that directory.

```c#
using System;
Expand All @@ -18,7 +18,7 @@ class Program
{
Process process = new Process();
process.StartInfo.FileName = "handle.exe";
process.StartInfo.Arguments = "filename";
process.StartInfo.Arguments = "filename"; // Replace 'filename' with the actual file or directory
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
Expand All @@ -31,8 +31,5 @@ class Program
}
```



参考资料:

References:
- https://learn.microsoft.com/zh-cn/sysinternals/downloads/handle
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,42 @@
sidebar_position: 1
---

### Permission 权限
### Permissions

#### (1)Windows平台
#### (1) Windows Platform

![](imgs\UAC.png)

在使用GeneralUpdate实现自动升级的时候,如果更新目录在C盘实现文件替换或打文件补丁时会出现权限问题。又因为windows11操作系统推出在C盘特定的目录相比之前推出的windows的操作系统加强了权限管理。
When using GeneralUpdate for automatic updates, you may encounter permission issues if the update directory is on the C drive, especially when replacing files or applying patches. With the introduction of Windows 11, permission management for certain directories on the C drive has become more stringent compared to previous Windows operating systems.

那么稍微不注意将会触碰到权限管理的边界,接下来我们看看操作哪些目录会导致出现权限问题:
It's important to be aware of which directories might trigger permission issues:

| 名称 | 目录 |
| -------------- | ------------------------------------------ |
| 系统文件夹 | C:\Windows |
| 注册表配置文件 | C:\Windows\System32\config |
| 驱动文件夹 | C:\Windows\System32\drivers |
| 程序文件夹 | C:\Program Files C:\Program Files (x86) |
| Name | Directory |
| --------------- | ------------------------------------------- |
| System Folder | C:\Windows |
| Registry Config | C:\Windows\System32\config |
| Driver Folder | C:\Windows\System32\drivers |
| Program Folder | C:\Program Files and C:\Program Files (x86) |

推荐使用目录,避免权限问题:
Recommended directories to avoid permission issues:

| 名称 | 目录 |
| ------------ | ------- |
| 用户数据目录 | AppData |
| 系统临时目录 | Temp |
| Name | Directory |
| -------------------------- | --------- |
| User Data Directory | AppData |
| System Temporary Directory | Temp |

### Lowering UAC

The following method is not recommended for use in production environments as it may cause issues for users. If you encounter UAC (User Account Control) prompts or permission/access denied issues during updates, you might consider lowering the UAC control level. This can be done by modifying the registry as follows:

### UAC降权
| Registry Name | New Value | Default Value |
| -------------------------- | --------- | ------------- |
| enableLUA | 0 | 1 |
| ConsentPromptBehaviorAdmin | 0 | 5 |

以下方法不推荐在生产环境中使用,以免给用户造成损失。如果在更新过程中出现UAC (User Account Control)提示或无权限、拒绝访问的情况可以考虑降低UAC控制等级,这个思路在代码层面可以通过修改以下注册表达到目的:
Modify the above registry settings before the update (effective after restarting the computer), and be sure to restore them after the update is complete.

| 注册表名称 | 修改值 | 默认值 |
| -------------------------- | ------ | ------ |
| enableLUA | 0 | 1 |
| ConsentPromptBehaviorAdmin | 0 | 5 |

更新之前修改以上注册表(重启计算机生效),切记更新完成之后需要恢复该内容。



c#修改注册表:
C# code to modify the registry:

```c#
using Microsoft.Win32;
Expand All @@ -61,19 +57,14 @@ public void UpdateRegistry()
}
```



bat批处理修改注册表:
Batch script to modify the registry:

```bat
@echo off
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA /t REG_DWORD /d 0 /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f
```



参考资料:

References:
- https://learn.microsoft.com/zh-cn/windows/security/application-security/application-control/user-account-control/how-it-works
- https://blog.walterlv.com/post/windows-user-account-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,36 @@
sidebar_position: 6
---

### System infomation 系统信息
### System Information

#### (1)Windows平台
#### (1) Windows Platform

当更新失败时,并不清楚是因为操作系统的原因还是其他原因导致的启动失败。这个时候可以使用PsInfo导出当前操作系统的信息,供开发人员进行问题排查。*PsInfo* 是一个命令行工具,它可用于收集有关本地或远程 Windows NT/2000 系统的关键信息,包括安装类型、内核版本、已注册的组织和所有者、处理器数量及其类型、物理内存量、系统的安装日期以及到期日期(如果为试用版)。
When an update fails, it might not be clear whether the failure is due to the operating system or other reasons. In such cases, you can use PsInfo to export information about the current operating system, which can help developers troubleshoot the issue. *PsInfo* is a command-line tool that can be used to collect critical information about local or remote Windows NT/2000 systems, including installation type, kernel version, registered organization and owner, number and type of processors, amount of physical memory, system installation date, and expiration date (if it is a trial version).

#### 使用 PsInfo
#### Using PsInfo

默认情况下,*PsInfo* 会显示本地系统的信息。 指定远程计算机名称以从远程系统获取信息。 由于 *PsInfo* 依赖于远程注册表访问来获取其数据,因此远程系统必须运行远程注册表服务,并且运行 *PsInfo* 的帐户必须有权访问远程注册表的 HKLM\System 部分。
By default, *PsInfo* displays information about the local system. Specify a remote computer name to retrieve information from a remote system. Since *PsInfo* relies on remote registry access to gather its data, the remote system must have the remote registry service running, and the account running *PsInfo* must have access to the HKLM\System section of the remote registry.

为了帮助自动更新 Service Pack*PsInfo* 会返回系统的 Service Pack 数的值(例如 0 表示无 Service Pack,1 表示 SP 1 等)。
To assist in automating Service Pack updates, *PsInfo* returns the system's Service Pack number (e.g., 0 for no Service Pack, 1 for SP 1, etc.).

**用法: psinfo [[\\computer[,computer[,..] | @file [-u user
[-p psswd]]] [-h] [-s] [-d] [-c [-t delimiter]] [filter]**
**Usage: psinfo [[\\computer[,computer[,..] | @file [-u user [-p psswd]]] [-h] [-s] [-d] [-c [-t delimiter]] [filter]**

| 参数 | 说明 |
| :------------- | :----------------------------------------------------------- |
| **\\computer** | 在指定的远程计算机上执行命令。 如果省略计算机名称,则命令在本地系统上运行,如果指定通配符 (\\*),则命令将在当前域中的所有计算机上运行。 |
| **@file** | 在指定的文本文件中列出的每台计算机上运行命令。 |
| **-u** | 指定登录远程计算机的可选用户名。 |
| **-p** | 指定用户名的可选密码。 如果省略此内容,系统将提示你输入隐藏密码。 |
| **-h** | 显示已安装的修补程序的列表。 |
| **-s** | 显示已安装的应用程序的列表。 |
| **-d** | 显示磁盘卷信息。 |
| **-c** | CSV 格式打印。 |
| **-t** | -c 选项的默认分隔符为逗号,但可以使用指定的字符替代。 |
| **filter** | Psinfo 将仅显示与筛选器匹配的字段的数据。 例如,“psinfo service”仅列出 service pack 字段。 |
| Parameter | Description |
| -------------- | ------------------------------------------------------------ |
| **\\computer** | Execute the command on the specified remote computer(s). If the computer name is omitted, the command runs on the local system. If a wildcard (\\*) is specified, the command runs on all computers in the current domain. |
| **@file** | Run the command on each computer listed in the specified text file. |
| **-u** | Specify an optional username for logging onto the remote computer. |
| **-p** | Specify an optional password for the username. If omitted, you will be prompted to enter a hidden password. |
| **-h** | Show a list of installed hotfixes. |
| **-s** | Show a list of installed applications. |
| **-d** | Show disk volume information. |
| **-c** | Print in CSV format. |
| **-t** | The default delimiter for the -c option is a comma, but you can specify a different character. |
| **filter** | PsInfo will only display data for fields that match the filter. For example, "psinfo service" will only list the service pack field. |

#### 示例输出
#### Example Output

When you run PsInfo, it will output information about the system in a structured format. This information can be used to diagnose and address any issues that may arise during the update process.

```c#
C:\> psinfo \\development -h -d
Expand Down Expand Up @@ -81,4 +82,4 @@ Sysinternals - www.sysinternals.com



官方文档:https://learn.microsoft.com/zh-cn/sysinternals/downloads/psinfo
References:https://learn.microsoft.com/zh-cn/sysinternals/downloads/psinfo
Loading

0 comments on commit 0afd7c5

Please sign in to comment.