Piggy CC

Pigg's Blog

中文使用英式键盘

No Comments »

April 22nd, 2024 Posted 02:28

问题概述

使用非美式键盘,使用微软内建的中文输入法,当激活拼音输入法(无论中英文模式)时,键盘布局永远是美式。结果就是输入符号时不符合键盘上的符号(甚至字母都不对,如果用的是非QWERTY的键盘布局)。

解决方案

按下Windows键(或者点击开始菜单按钮)输入 regedit,回车或者点击注册表编辑器。进入 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts 然后一个一个找(可以使用方向键翻,用鼠标点可能会点疯),找到你要修改的语言,例如这里我要改的是简体中文,文件夹00000804对应的就是简体中文的键盘布局 (Layout Text 的值是 Chinese (Simplified) - US Keyboard),双击 Layout File 把值从 KBDUS.DLL 改成 KBDUK.DLL,可以顺便把 Layout Text 的值里面的 US Keyboard 改成 UK Keyboard。修改完成后需要重启电脑(或者登出再登入)生效。

Posted in Notes

PHP and SQLite

No Comments »

April 8th, 2024 Posted 02:30

PHP and SQLite: Lightweight SQL Database for PHP

In this tutorial, we will explore PHP and SQLite, a powerful combination that enables developers to create lightweight and efficient SQL databases for their PHP applications. SQLite is a serverless, self-contained database engine that is easy to set up and requires minimal configuration. By the end of this tutorial, you will have a solid understanding of how to use SQLite with PHP and will be ready to build your own database-driven applications.

Table of Contents

  1. Introduction to SQLite
  2. Installing SQLite on Your System
  3. Creating a SQLite Database in PHP
  4. Executing SQLite Queries in PHP
  5. Fetching Results from SQLite Queries
  6. Error Handling and Debugging
  7. Conclusion

1. Introduction to SQLite

SQLite is a lightweight, self-contained, and serverless SQL database engine that is increasingly popular for its ease of use and minimal setup requirements. Unlike other SQL databases like MySQL or PostgreSQL, SQLite does not require a separate server process to manage the database. Instead, it reads and writes directly to a single disk file.

Some of the benefits of using SQLite with PHP include:

  • Serverless architecture: No need for a dedicated server process
  • Portable and self-contained: No external dependencies and easy to install
  • Fast and efficient: Offers good performance even for large databases
  • ACID-compliant: Ensures data integrity and consistency
  • Flexible and extensible: Supports user-defined functions and extensions

2. Installing SQLite on Your System

To use SQLite with PHP, you need to have the SQLite extension enabled in your PHP installation. The SQLite extension is enabled by default in PHP 5.3.0 and later versions. To check if SQLite is enabled on your system, you can use the following command:

php -i | grep -i sqlite
PHP

If SQLite is not enabled, you can enable it by editing your `php.ini` file and adding the following line:

extension=sqlite3
PHP

After enabling the SQLite extension, restart your web server for the changes to take effect.

3. Creating a SQLite Database in PHP

To create a new SQLite database in PHP, use the `SQLite3` class. The constructor of this class accepts a file path as a parameter, which will be used to store the database. If the file does not exist, SQLite will create it automatically. Here’s an example:


$database = new SQLite3('my_database.sqlite');
PHP

This code creates a new SQLite database named `my_database.sqlite` in the same directory as the PHP script. You can also use an in-memory database by passing `:memory:` as the file path:


$database = new SQLite3(':memory:');
PHP

4. Executing SQLite Queries in PHP

To execute an SQL query in PHP, you can use the `exec` method of the `SQLite3` class. This method takes an SQL query string as its parameter and returns `true` on success, or `false` on failure. Here’s an example of how to create a table and insert some data:


// Create a table
$database->exec('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)');

// Insert data
$database->exec("INSERT INTO users (name, email) VALUES ('John Doe', 'john.doe@example.com')");
$database->exec("INSERT INTO users (name, email) VALUES ('Jane Doe', 'jane.doe@example.com')");
PHP

5. Fetching Results from SQLite Queries

To fetch the results of a SELECT query, you can use the `query` method of the `SQLite3` class. This method takes an SQL query string as its parameter and returns an instance of the `SQLite3Result` class, which you can use to fetch the rows of the result set. Here’s an example:


// Query the database
$result = $database->query('SELECT * FROM users');

// Fetch rows as associative arrays
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
  echo 'ID: ' . $row['id'] . ' Name: ' . $row['name'] . ' Email: ' . $row['email'] . '<br>';
}
PHP

6. Error Handling and Debugging

To handle errors and debug your SQLite queries in PHP, use the `lastErrorCode` and `lastErrorMsg` methods of the `SQLite3` class. These methods return the error code and message of the last operation, respectively. Here’s an example:


// Execute a query with an error
$database->exec('SELECT * FROM non_existent_table');

// Check for errors
if ($database->lastErrorCode()) {
  echo 'Error Code: ' . $database->lastErrorCode() . '<br>';
  echo 'Error Message: ' . $database->lastErrorMsg() . '<br>';
}
PHP

Posted in Notes

windows关机自动还原设置UWF

No Comments »

April 4th, 2024 Posted 21:47

Unified Write Filter.

http://woshub.com/using-unified-write-filter-uwf-windows-10/

1、UWF是一个独立的系统组件,在“控制面板”->“程序和功能”->“打开或关闭Windows功能”->“设备锁定”->“统一写入筛选器”中启用。

2、若要启用UWF,请运行此命令并重新启动计算机:uwfmgr.exe文件过滤器启用。
3、启用筛选器后,它将自动重新配置系统以消除任何写入操作(禁用了交换文件,还原点,文件索引编制,碎片整理)。

特定系统磁盘启用写保护,请运行以下命令:
uwfmgr.exe volume protect c:

现在重新启动计算机。重新启动后,用户在会话期间写入磁盘的所有内容将仅在下一次重新启动之前可用。
您可以使用以下命令检查UWF状态:
uwfmgr.exe get-config

要将特定文件或文件夹添加到排除项,请运行以下命令:
Uwfmgr.exe file add-exclusion c:\labs

Uwfmgr.exe file add-exclusion c:\labs\report.docx

要为注册表项添加排除项:
Uwfmgr.exe registry add-exclusion “HKLM\Software\My_RegKey”

在开始维护(更新安装,防病毒软件更新,复制新文件)之前,您将必须切换到特殊服务模式:
Uwfmgr.exe servicing enable

Posted in Notes

VS Code Predefined variables

No Comments »

April 4th, 2024 Posted 01:11

Predefined variables

The following predefined variables are supported:

  • ${userHome} – the path of the user’s home folder
  • ${workspaceFolder} – the path of the folder opened in VS Code
  • ${workspaceFolderBasename} – the name of the folder opened in VS Code without any slashes (/)
  • ${file} – the current opened file
  • ${fileWorkspaceFolder} – the current opened file’s workspace folder
  • ${relativeFile} – the current opened file relative to workspaceFolder
  • ${relativeFileDirname} – the current opened file’s dirname relative to workspaceFolder
  • ${fileBasename} – the current opened file’s basename
  • ${fileBasenameNoExtension} – the current opened file’s basename with no file extension
  • ${fileExtname} – the current opened file’s extension
  • ${fileDirname} – the current opened file’s folder path
  • ${fileDirnameBasename} – the current opened file’s folder name
  • ${cwd} – the task runner’s current working directory upon the startup of VS Code
  • ${lineNumber} – the current selected line number in the active file
  • ${selectedText} – the current selected text in the active file
  • ${execPath} – the path to the running VS Code executable
  • ${defaultBuildTask} – the name of the default build task
  • ${pathSeparator} – the character used by the operating system to separate components in file paths
  • ${/} – shorthand for ${pathSeparator}

Predefined variables examples

Supposing that you have the following requirements:

  1. A file located at /home/your-username/your-project/folder/file.ext opened in your editor;
  2. The directory /home/your-username/your-project opened as your root workspace.

So you will have the following values for each variable:

  • ${userHome} – /home/your-username
  • ${workspaceFolder} – /home/your-username/your-project
  • ${workspaceFolderBasename} – your-project
  • ${file} – /home/your-username/your-project/folder/file.ext
  • ${fileWorkspaceFolder} – /home/your-username/your-project
  • ${relativeFile} – folder/file.ext
  • ${relativeFileDirname} – folder
  • ${fileBasename} – file.ext
  • ${fileBasenameNoExtension} – file
  • ${fileDirname} – /home/your-username/your-project/folder
  • ${fileExtname} – .ext
  • ${lineNumber} – line number of the cursor
  • ${selectedText} – text selected in your code editor
  • ${execPath} – location of Code.exe
  • ${pathSeparator} – / on macOS or linux, \ on Windows

Tip: Use IntelliSense inside string values for tasks.json and launch.json to get a full list of predefined variables.

Variables scoped per workspace folder

By appending the root folder’s name to a variable (separated by a colon), it is possible to reach into sibling root folders of a workspace. Without the root folder name, the variable is scoped to the same folder where it is used.

For example, in a multi root workspace with folders Server and Client, a ${workspaceFolder:Client} refers to the path of the Client root.

Environment variables

You can also reference environment variables through the ${env:Name} syntax (for example, ${env:USERNAME}).

{
  "type": "node",
  "request": "launch",
  "name": "Launch Program",
  "program": "${workspaceFolder}/app.js",
  "cwd": "${workspaceFolder}",
  "args": ["${env:USERNAME}"]
}

Configuration variables

You can reference VS Code settings (“configurations”) through ${config:Name} syntax (for example, ${config:editor.fontSize}).

Command variables

If the predefined variables from above are not sufficient, you can use any VS Code command as a variable through the ${command:commandID} syntax.

A command variable is replaced with the (string) result from the command evaluation. The implementation of a command can range from a simple calculation with no UI, to some sophisticated functionality based on the UI features available via VS Code’s extension API. If the command returns anything other than a string, then the variable replacement will not complete. Command variables must return a string.

An example of this functionality is in VS Code’s Node.js debugger extension, which provides an interactive command extension.pickNodeProcess for selecting a single process from the list of all running Node.js processes. The command returns the process ID of the selected process. This makes it possible to use the extension.pickNodeProcess command in an Attach by Process ID launch configuration in the following way:

{
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach by Process ID",
      "processId": "${command:extension.pickNodeProcess}"
    }
  ]
}

When using a command variable in a launch.json configuration, the enclosing launch.json configuration is passed as an object to the command via an argument. This allows commands to know the context and parameters of the specific launch.json configuration when they are called.

Input variables

Command variables are already powerful but they lack a mechanism to configure the command being run for a specific use case. For example, it is not possible to pass a prompt message or a default value to a generic “user input prompt”.

This limitation is solved with input variables which have the syntax: ${input:variableID}. The variableID refers to entries in the inputs section of launch.json and tasks.json, where additional configuration attributes are specified. Nesting of input variables is not supported.

The following example shows the overall structure of a tasks.json that makes use of input variables:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "task name",
      "command": "${input:variableID}"
      // ...
    }
  ],
  "inputs": [
    {
      "id": "variableID",
      "type": "type of input variable"
      // type specific configuration attributes
    }
  ]
}

Currently VS Code supports three types of input variables:

  • promptString: Shows an input box to get a string from the user.
  • pickString: Shows a Quick Pick dropdown to let the user select from several options.
  • command: Runs an arbitrary command.

Each type requires additional configuration attributes:

promptString:

  • description: Shown in the quick input, provides context for the input.
  • default: Default value that will be used if the user doesn’t enter something else.
  • password: Set to true to input with a password prompt that will not show the typed value.

pickString:

  • description: Shown in the quick pick, provides context for the input.
  • options: An array of options for the user to pick from.
  • default: Default value that will be used if the user doesn’t enter something else. It must be one of the option values.

An option can be a string value or an object with both a label and value. The dropdown will display label: value.

command:

  • command: Command being run on variable interpolation.
  • args: Optional option bag passed to the command’s implementation.

Below is an example of a tasks.json that illustrates the use of inputs using Angular CLI:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "ng g",
      "type": "shell",
      "command": "ng",
      "args": ["g", "${input:componentType}", "${input:componentName}"]
    }
  ],
  "inputs": [
    {
      "type": "pickString",
      "id": "componentType",
      "description": "What type of component do you want to create?",
      "options": [
        "component",
        "directive",
        "pipe",
        "service",
        "class",
        "guard",
        "interface",
        "enum"
      ],
      "default": "component"
    },
    {
      "type": "promptString",
      "id": "componentName",
      "description": "Name your component.",
      "default": "my-new-component"
    }
  ]
}

Running the example:

Inputs Example

The following example shows how to use a user input variable of type command in a debug configuration that lets the user pick a test case from a list of all test cases found in a specific folder. It is assumed that some extension provides an extension.mochaSupport.testPicker command that locates all test cases in a configurable location and shows a picker UI to pick one of them. The arguments for a command input are defined by the command itself.

{
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Run specific test",
      "program": "${workspaceFolder}/${input:pickTest}"
    }
  ],
  "inputs": [
    {
      "id": "pickTest",
      "type": "command",
      "command": "extension.mochaSupport.testPicker",
      "args": {
        "testFolder": "/out/tests"
      }
    }
  ]
}

Command inputs can also be used with tasks. In this example, the built-in Terminate Task command is used. It can accept an argument to terminate all tasks.

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Terminate All Tasks",
      "command": "echo ${input:terminate}",
      "type": "shell",
      "problemMatcher": []
    }
  ],
  "inputs": [
    {
      "id": "terminate",
      "type": "command",
      "command": "workbench.action.tasks.terminate",
      "args": "terminateAll"
    }
  ]
}

Common questions

Details of variable substitution in a debug configuration or task

Variable substitution in debug configurations or tasks is a two pass process:

  • In the first pass, all variables are evaluated to string results. If a variable occurs more than once, it is only evaluated once.
  • In the second pass, all variables are substituted with the results from the first pass.

A consequence of this is that the evaluation of a variable (for example, a command-based variable implemented in an extension) has no access to other substituted variables in the debug configuration or task. It only sees the original variables. This means that variables cannot depend on each other (which ensures isolation and makes substitution robust against evaluation order).

Is variable substitution supported in User and Workspace settings?

The predefined variables are supported in a select number of setting keys in settings.json files such as the terminal cwdenvshell and shellArgs values. Some settings like window.title have their own variables:

  "window.title": "${dirty}${activeEditorShort}${separator}${rootName}${separator}${appName}"

Refer to the comments in the Settings editor (Ctrl+,) to learn about setting specific variables.

Why isn’t ${workspaceRoot} documented?

The variable ${workspaceRoot} was deprecated in favor of ${workspaceFolder} to better align with Multi-root Workspace support.

Why aren’t variables in tasks.json being resolved?

Not all values in tasks.json support variable substitution. Specifically, only commandargs, and options support variable substitution. Input variables in the inputs section will not be resolved as nesting of input variables is not supported.

How can I know a variable’s actual value?

One easy way to check a variable’s runtime value is to create a VS Code task to output the variable value to the console. For example, to see the resolved value for ${workspaceFolder}, you can create and run (Terminal > Run Task) the following simple ‘echo’ task in tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "echo",
      "type": "shell",
      "command": "echo ${workspaceFolder}"
    }
  ]
}

Posted in Notes

ssadmin命令行管理卷影副本

No Comments »

April 3rd, 2024 Posted 22:20

Windows 11版本 7条

vssadmin /?
vssadmin 1.1 – 卷影复制服务管理命令行工具
(C) 版权所有 2001-2013 Microsoft Corp.

—- 支持的命令 —-

Delete Shadows        – 删除卷影副本
List Providers        – 列出已注册的卷影副本提供程序
List Shadows          – 列出现有卷影副本
List ShadowStorage    – 列出卷影副本存储关联
List Volumes          – 列出可以进行卷影副本处理的卷
List Writers          – 列出订阅的卷影副本写入程序
Resize ShadowStorage  – 调整卷影副本存储关联的大小

在 Windows 10 中,可以使用vssadmin命令行工具进行卷影副本的管理。以下是一些常用的卷影副本命令:

创建卷影副本:
vssadmin create shadow /for=<驱动器>
例如:

vssadmin create shadow /for=C:
这将在C盘上创建一个卷影副本。

删除卷影副本:
vssadmin delete shadows /for=<驱动器> [/all]
例如:

vssadmin delete shadows /for=C:
这将删除C盘上的所有卷影副本。如果要删除所有驱动器上的卷影副本,可以添加/all参数:

vssadmin delete shadows /all
列出卷影副本:
vssadmin list shadows [/for=<驱动器>]
例如:

vssadmin list shadows /for=C:
这将列出C盘上的所有卷影副本。如果要列出所有驱动器上的卷影副本,可以省略/for参数:

vssadmin list shadows

查询卷影副本提供者:
vssadmin list providers
该命令用于列出系统上安装的所有卷影副本提供者。

查询卷影副本设置:
vssadmin list shadowstorage [/for=<驱动器>]
该命令用于列出指定驱动器或所有驱动器的卷影副本存储设置,包括卷影副本的最大存储空间和当前使用的存储空间。

设置卷影副本存储空间大小:
vssadmin resize shadowstorage /for=<驱动器> /on=<驱动器> /maxsize=<大小>
该命令用于设置指定驱动器上的卷影副本存储空间的最大大小。需要指定被保护的驱动器和存储卷影副本的驱动器(可以是相同的驱动器),并指定最大大小(例如:10GB)。

显示卷影副本的属性:
vssadmin list shadows [/shadow=<卷影副本ID>]
该命令用于列出指定卷影副本或所有卷影副本的详细属性,包括卷影副本的ID、创建时间、状态等信息。

 


Windows Volume Shadow Copy Service(VSS)是一项重要的数据备份技术,它可以创建文件或卷的快照,即使文件正在使用中也能保证数据的一致性。VSS 通过与操作系统、存储服务以及应用程序的紧密集成,确保了备份过程的高效和准确。

在 Windows 10 系统中,VSS 相关的配置信息部分存储于注册表中。注册表中与 VSS 相关的键主要集中在以下几个位置:

  1. VSS 服务配置
    • 路径:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\VSS
    • 此处主要包含了 VSS 服务的启动类型、错误控制等基本配置信息。
  2. VSS 提供者
    • 路径:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\VolumeShadowCopy
    • 在这个部分中包含了 VSS 的提供者信息。VSS 提供者负责创建、管理卷影副本。Windows 自带的提供者有 Microsoft Software Shadow Copy provider 1.0 等。
  3. VSS 编写器
    • 路径:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\VolumeShadowCopy\Writers
    • VSS 编写器负责确保备份过程中数据的一致性。例如,数据库系统在进行备份时可能需要执行特定的操作以确保数据一致性。在这个部分下,会列出系统中所有注册的 VSS 编写器及其状态信息。
  4. VSS 诊断
    • 路径:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\VolumeShadowCopy\Diagnostics
    • 这里包含了用于故障排查和性能监控的配置选项。
  5. VSS 客户端备份设置
    • 路径:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\VolumeShadowCopy\SnapshotSets
    • 这部分记录了当前系统上的快照集合的信息,通常用于高级故障排除。

 


VSSAdmin(Volume Shadow Copy Service administration tool)是用于管理Windows系统卷影复制服务的命令行工具。以下是VSSAdmin命令的初级、中级和高级应用实例:

初级应用实例

  • 显示当前系统中的所有卷信息:运行以下命令可以列出当前系统中的所有卷信息:
    Copy Code
    vssadmin list volumes

中级应用实例

  • 创建新的卷影复制快照:通过VSSAdmin命令可以创建新的卷影复制快照,用于备份或还原文件。例如,创建一个名为“MySnapshot”的新快照:
    Copy Code
    vssadmin create shadow /for=C:
  • 删除特定卷的卷影复制快照:可以使用VSSAdmin命令删除特定卷的卷影复制快照。例如,删除卷C:上的所有快照:
    Copy Code
    vssadmin delete shadows /for=C: /all

高级应用实例

  • 设置卷影复制存储空间限制:通过VSSAdmin命令可以设置卷影复制服务的存储空间限制,避免快照占用过多空间。例如,将卷C:上的卷影复制存储空间限制设置为5GB:
    Copy Code
    vssadmin resize shadowstorage /on=C: /for=C: /maxsize=5GB
  • 导出和导入卷影复制配置:可以使用VSSAdmin命令导出和导入卷影复制配置,方便在不同系统间迁移配置或备份配置信息。例如,导出卷C:上的卷影复制配置到文件snapshot.cfg:
    Copy Code
    vssadmin create shadow /for=C:
    vssadmin add shadowstorage /for=C: /on=C: /maxsize=5GB
    vssadmin export shadowstorage /for=C: /file=snapshot.cfg

这些初级、中级和高级应用实例展示了VSSAdmin命令在不同场景下的功能和用法,帮助用户更好地管理和利用Windows系统中的卷影复制服务。根据具体需求选择合适的命令和参数,可以提高系统数据备份和恢复的效率和可靠性。


VSSAdmin命令与其他多个命令组合的初级、中级和高级应用实例:

初级应用实例

  • 创建快照并备份文件:结合使用VSSAdmin命令创建快照和XCOPY命令备份文件。例如,创建快照后将文件复制到备份目录:
    Copy Code
    vssadmin create shadow /for=C:
    xcopy C:\SourceFolder D:\BackupFolder /E /C /H /R /K /Y

中级应用实例

  • 创建快照并使用Robocopy备份文件:结合使用VSSAdmin命令创建快照和Robocopy命令备份文件。例如,创建快照后使用Robocopy将文件同步到备份目录:
    Copy Code
    vssadmin create shadow /for=C:
    robocopy C:\SourceFolder D:\BackupFolder /MIR /Z /COPYALL /R:5 /W:5 /LOG:D:\BackupLog.txt

高级应用实例

  • 创建快照、备份文件并压缩:结合使用VSSAdmin命令创建快照、XCOPY命令备份文件和7-Zip命令压缩文件。例如,创建快照后将文件备份到备份目录并使用7-Zip压缩:
    Copy Code
    vssadmin create shadow /for=C:
    xcopy C:\SourceFolder D:\BackupFolder /E /C /H /R /K /Y
    7z a D:\Backup.zip D:\BackupFolder

这些组合应用实例可以提高数据备份和恢复的效率,并且能够在不同场景下灵活应对数据管理需求。根据具体情况选择合适的命令组合,并确保命令的正确性和安全性,以确保数据的完整性和可靠性。


VSSAdmin命令与其他多个命令以及REG文件组合的初级、中级和高级应用实例:

初级应用实例

  • 创建快照并导出注册表:结合使用VSSAdmin命令创建快照和REG命令导出注册表。例如,创建快照后导出注册表到REG文件:
    Copy Code
    vssadmin create shadow /for=C:
    reg export HKEY_LOCAL_MACHINE\Software D:\RegistryBackup.reg

中级应用实例

  • 创建快照、导出注册表并备份文件:结合使用VSSAdmin命令创建快照、REG命令导出注册表和XCOPY命令备份文件。例如,创建快照后导出注册表并将文件备份到备份目录:
    Copy Code
    vssadmin create shadow /for=C:
    reg export HKEY_LOCAL_MACHINE\Software D:\RegistryBackup.reg
    xcopy C:\SourceFolder D:\BackupFolder /E /C /H /R /K /Y

高级应用实例

  • 创建快照、导出注册表、备份文件并压缩:结合使用VSSAdmin命令创建快照、REG命令导出注册表、XCOPY命令备份文件和7-Zip命令压缩文件。例如,创建快照后导出注册表、备份文件并使用7-Zip压缩:
    Copy Code
    vssadmin create shadow /for=C:
    reg export HKEY_LOCAL_MACHINE\Software D:\RegistryBackup.reg
    xcopy C:\SourceFolder D:\BackupFolder /E /C /H /R /K /Y
    7z a D:\Backup.zip D:\RegistryBackup.reg D:\BackupFolder

这些组合应用实例结合了VSSAdmin命令、REG命令和其他文件操作命令,可以在数据备份和系统管理中发挥重要作用。根据实际需求选择合适的命令组合,并确保命令的正确性和安全性,以保护数据和系统的稳定性。


卷影副本是 Windows 操作系统中的一个功能,它可以创建系统在某个时间点的快照,以便在需要时还原文件或文件夹到该时间点的状态。在命令行下,可以使用一些命令来管理卷影副本,包括:

  1. vssadminvssadmin 是 Windows 系统中用于管理卷影副本的主要命令。它提供了各种子命令来执行不同的操作,如创建快照、列出快照、删除快照等。以下是一些常用的 vssadmin 子命令:
    • vssadmin list shadows: 列出当前系统上存在的所有卷影副本。
    • vssadmin list shadowstorage: 列出当前系统上各卷的卷影副本存储信息。
    • vssadmin create shadow /for=<Volume>: 为指定卷创建一个卷影副本。
    • vssadmin delete shadows /for=<Volume> [/oldest | /shadow=<ShadowID>]: 删除指定卷的卷影副本,可以选择删除最旧的或指定 ID 的快照。
  2. DiskShadowDiskShadow 是一个命令行实用程序,用于管理卷影副本。它提供了更高级的功能,可以通过脚本进行自动化管理。以下是一些常用的 DiskShadow 命令:
    • diskshadow /l <script.txt>: 使用脚本文件执行 DiskShadow 命令。
    • diskshadow /s <script.txt>: 使用交互式 Shell 执行 DiskShadow 命令。
    • ADD VOLUME <Volume>: 添加指定卷到卷影副本的作用域。
    • CREATE: 创建卷影副本。
    • DELETE SHADOWS: 删除卷影副本。
  3. PowerShell Cmdlets: PowerShell 提供了一组与卷影副本相关的 Cmdlets,可以通过 PowerShell 来管理卷影副本。一些常用的 Cmdlets 包括:
    • Get-WmiObject: 用于检索与 Windows 管理体系结构 (WMI) 相关的信息,可以用于获取卷影副本的信息。
    • New-VSSSnapshot: 创建卷影副本。
    • Remove-VSSSnapshot: 删除卷影副本。
  4. Shadow Copies for Shared Folders: 如果在系统上启用了共享文件夹的卷影副本功能,则可以使用一些专门用于管理共享文件夹卷影副本的命令,包括:
    • vssadmin add shadowstorage: 为共享文件夹指定卷添加卷影副本存储。
    • vssadmin resize shadowstorage: 调整共享文件夹的卷影副本存储大小。
    • vssadmin create shadow /for=<SharedFolder>: 为指定共享文件夹创建卷影副本。
  5. Windows Server Backup: Windows Server Backup 是 Windows Server 系统中提供的备份和恢复工具,它也可以用于管理卷影副本。通过 Windows Server Backup,管理员可以备份和还原整个卷影副本,以及配置备份策略等。

这些命令可以在管理员需要对系统中的卷影副本进行管理时使用。通过这些命令,管理员可以执行创建、列出、删除等操作,以确保卷影副本的正确管理和使用。

Posted in Notes

WordPress评论设置微信实时提醒

No Comments »

March 25th, 2024 Posted 23:28

WordPress评论设置微信实时提醒

对于一些企业(外贸)网站来说,能够及时收到客户在网站上的留言非常重要,但是我们又不可能每时每刻都查看网站后台里面的(评论)留言,所以今天我们就来介绍一种将网站评论(留言或者询盘)转发到邮箱,然后把邮箱和微信绑定,最终可以通过微信来即时接收网站的询盘信息的方法。

为什么要用Wordpress自带的有评论功能?

WordPress自带的评论功能十分好用,尤其在建设企业站的时候我通常会直接将评论功能作为留言模块,优点是不用再额外使用其它留言插件,并且系统有自带的评论转发邮件功能,不仅可以使网站更加简洁纯净,而且在后期的邮件转发设置方面更加方便。

WordPress评论设置微信实时提醒方法

首先,在网站上使用评论功能作为留言版块这里可能需要自己情况修改一些东西。

其次,开启网站评论邮件转发功能,登录网站后台,找到Settings-Discussion-Email me whenever,默认两项都是勾选,如果没有,则勾选即可。

开启评论邮件通知

开启评论邮件通知

这样我们设置的管理员邮箱就可以收到评论了。这要比使用留言插件,然后再使用邮件转发插件获取留言方便多了。

设置管理员邮箱

设置管理员邮箱

然后,将管理员邮箱收到的评论邮件转发到QQ邮箱。如果你的管理员邮箱使用的是QQ邮箱,可以直接跳过这一步。

这里我们以Gmail邮箱为例,设置Gmail邮箱为管理员邮箱,并将其接收到的评论邮件转发至QQ邮箱。

登录Gmail邮箱,然后点击右上角设置图标查看所有设置转发和POP/IMAP,填写要转发的QQ邮箱,后面选择在收件箱中保留Gmail的副本,等于是多了个一个备份,最后保存即可。

Gmail邮箱转发设置

Gmail邮箱转发设置

最后,设置QQ邮箱在微信上提醒,登录微信设置通用辅助功能-QQ邮箱提醒填写相应的QQ邮箱地址

QQ邮箱设置微信提醒

QQ邮箱设置微信提醒

然后如果QQ邮箱有收到新的邮件,就会在微信上直接提醒。

微信显示邮件提醒

微信显示邮件提醒

此外,还需要注意两点:

  • 在设置邮件转发时(比如Gmail邮件转发到QQ邮箱),在收件邮箱里面把发件邮箱设置为白名单,以免邮件确实或者漏掉。QQ邮箱白名单具体设置方法:登录邮箱设置反垃圾白名单把邮箱地址添加到白名单
    邮箱白名单设置

    邮箱白名单设置

  • 微信邮件提醒只是一个辅助工具,帮助我们能够及时收到邮件信息,从而及时回复客户,但是如果邮件被确定为垃圾邮件,可能不会被转发或者不在微信提醒,所以即使有了微信提醒,也要注意查看原邮箱邮件以及网站后台评论,以免有错失。

转发自: https://www.dajianbiji.com/website-building/comments-on-wechat-alerts/

Posted in Notes

如何使用WordPress评论功能做自定义留言表单?

No Comments »

March 25th, 2024 Posted 23:25

使用Wordpress自带的评论功能做网站表单,不仅方便简洁,而且可以直接设置邮件自动转发提醒,但是由于其自带的评论功能比较简单,所以要想作为网站的留言表单还需要进行一些自定义修改。先看下最终效果:

自带的评论功能做自定义网站留言表单

在修改之前,需要先了解以下几点:

系统默认存在的字段有:作者(姓名)邮箱地址评论内容评论页面提交时间以及IP地址,这几个我们一般是可以直接拿来用的,只需要修改下展示名称,英文网站也是一样,比如将作者改为Name等,如果实在不需要可以进行删除。

具体修改方法如下:(除了CSS以下代码都是添加到对应主题目录下的functions.php文件中)

  1. 删除评论模块中不需要的字段

    示例:删除url字段即评论页面地址

    function url_filtered($fields)
    {
    if(isset($fields['url']))
    unset($fields['url']);
    return $fields;
    }
    add_filter('comment_form_default_fields', 'url_filtered');

  2. 添加额外的自定义字段

    比如除了现有的字段外,我们还需要客户的电话或者所处的国家地区。

    示例:添加电话字段phone和国家字段country

    add_filter('comment_form_default_fields','comment_form_add_phc');
    function comment_form_add_phc($fields) {
    $label1 = __( 'Phone/Whatsapp' );
    $label2 = __( 'Country' );
    $value1 = isset($_POST['phone']) ? $_POST['phone'] : false;
    $value2 = isset($_POST['country']) ? $_POST['country'] : false;
    $fields['phone'] =<<<HTML
    <p class="comment-form-phone">
    <label for="phone">{$label1}</label>
    <input id="phone" class="blog-form-input" placeholder="Your Phone/Whatsapp "
    name="phone" type="text" value="{$value1}" size="30" />
    </p>
    HTML;
    $fields['country'] =<<<HTML
    <p class="comment-form-country">
    <label for="country">{$label2}</label>
    <input id="country" class="blog-form-input" placeholder="Your Country " name="country"
    type="text" value="{$value2}" size="30" />
    </p>
    HTML;
    return $fields;
    }

  3. 将自定义的评论字段添加到网站数据库

    示例:将电话字段phone和国家字段country添加到数据库

    add_action('wp_insert_comment','wp_insert_phone',10,2);
    function wp_insert_phone($comment_ID,$commmentdata) {
    $phone = isset($_POST['phone']) ? $_POST['phone'] : false;
    $country = isset($_POST['country']) ? $_POST['country'] : false;
    update_comment_meta($comment_ID,'_country',$country);
    update_comment_meta($comment_ID,'_phone',$phone);
    }

  4. 将自定义的评论字段添加到网站后台评论界面

    示例:将电话字段phone和国家字段country显示在后台评论页面

    网站后台显示新添加的字段

    网站后台显示新添加的字段

    add_filter( 'manage_edit-comments_columns', 'my_comments_columns' );
    add_action( 'manage_comments_custom_column', 'output_my_comments_columns', 10, 2 );
    function my_comments_columns( $columns ){
    $columns[ '_phone' ] = __( 'Phone' );
    $columns[ '_country' ] = __( 'Country' );
    return $columns;
    }
    function output_my_comments_columns( $column_name, $comment_id ){
    switch( $column_name ){
    case '_phone';
    echo get_comment_meta( $comment_id, '_phone', true );
    break;
    case '_country';
    echo get_comment_meta( $comment_id, '_country', true );
    break;
    }}

  5. 将自定义后的评论代码添加到相应的页面模板

    示例:将以上自定义评论代码添加到需要的页面或者模板中

    <?php
    $comments_args = array(
    // Change the title of send button
    'label_submit' => __( 'SEND MESSAGE', 'textdomain' ),
    // Change the title of the reply section
    'title_reply' => __( 'INQUIRY', 'textdomain' ),
    // Redefine your own textarea (the comment body).
    'comment_field' => '<p class="comment-form-comment">' . '<label for="author">' . __( 'Message:*' ) .
    '</label> ' . '<textarea id="comment" class="blog-form-input-area" name="comment"
    placeholder="Please enter the information you want to know" aria-required="true"></textarea></p>',
    'fields' => apply_filters( 'comment_form_default_fields', array(
    'author' =>
    '<p class="comment-form-author">' . '<label for="author">' . __( 'Your Name*' ) . '</label> ' .
    '<input id="author" class="blog-form-input" placeholder="Your Name* " name="author"
    type="text" value="' . esc_attr( $commenter['comment_author'] ) .
    '" size="30"' . $aria_req . ' /></p>',
    'email' =>
    '<p class="comment-form-email">'. '<label for="author">' . __( 'Your email:*' ) . '</label> ' .
    '<input id="email" class="blog-form-input" placeholder="Your Email Address* "
    name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) .
    '" size="30"' . $aria_req . ' /></p>',
    )
    ),
    );
    comment_form( $comments_args );
    ?>

  6. 通过CSS进行评论表单样式修改

    因为每个人多表单样式要求不同,这里就不在列出相关的CSS代码

最后需要注意的是调用评论表单的时候 一定要把对应的页面开启评论功能,否则前端页面不显示。

示例:将电话字段phone和国家字段country显示在后台评论页面

开启页面评论功能

开启页面评论功能

转发自: https://www.dajianbiji.com/website-building/wp-message-form/

Posted in Notes

禁用所有 wordpress plugins

No Comments »

March 25th, 2024 Posted 22:56

进入MariaDB

mysql -h localhost -u root -p

use DB_Name;

UPDATE wp_options SET option_value = ” WHERE option_name = ‘active_plugins’;

Posted in Notes

添加SSL证书支持https

No Comments »

April 5th, 2018 Posted 02:04

使用Let’s encrypt证书支持https
添加cron自动更新证书

Posted in Notes

搬家

No Comments »

April 3rd, 2018 Posted 23:56

六爻,日历页面源文件因为使用ANSI编码导致搬家后页面乱码。
抓取后的数据使用iconv转码出错,应为gbk,不是gb2312。
在php代码中加入:ini_set(“display_errors”,1); 开启错误提示
浏览器自动侦测为utf-8仍未解决
ps:关闭自动升级

Posted in Notes