Skip to content

Commit 066009c

Browse files
committed
增加内部命令
1 parent 950e689 commit 066009c

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "command-manager",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"private": true,
55
"scripts": {
66
"start": "vue-cli-service serve --port 27000",

shell/internal/cmd.reg

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Windows Registry Editor Version 5.00
2+
[-HKEY_CLASSES_ROOT\Directory\shell\runas]
3+
[HKEY_CLASSES_ROOT\Directory\shell\runas]
4+
@="以管理员身份运行命令行"
5+
"HasLUAShield"=""
6+
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
7+
@="cmd.exe /s /k pushd \"%V\""
8+
[-HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
9+
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas]
10+
@="以管理员身份运行命令行"
11+
"HasLUAShield"=""
12+
[HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command]
13+
@="cmd.exe /s /k pushd \"%V\""
14+
[-HKEY_CLASSES_ROOT\Drive\shell\runas]
15+
[HKEY_CLASSES_ROOT\Drive\shell\runas]
16+
@="以管理员身份运行命令行"
17+
"HasLUAShield"=""
18+
[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
19+
@="cmd.exe /s /k pushd \"%V\""
20+
[-HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas]
21+
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas]
22+
"HasLUAShield"=""
23+
@="以管理员身份运行命令行"
24+
[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\runas\command]

shell/internal/package1.ps1

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Add-Type -AssemblyName System.Windows.Forms
2+
Add-Type -AssemblyName System.Drawing
3+
if (Test-Path package.json) {
4+
$config = Get-Content package.json | ConvertFrom-Json
5+
$scrips = $config.scripts
6+
$width = 280
7+
$height = 320
8+
$form = New-Object System.Windows.Forms.Form
9+
$form.Text = '执行脚本'
10+
$form.Size = New-Object System.Drawing.Size($width, $height)
11+
$form.StartPosition = 'CenterScreen'
12+
$form.FormBorderStyle = 'FixedDialog';
13+
14+
$okButton = New-Object System.Windows.Forms.Button
15+
$okButton.Location = New-Object System.Drawing.Point(-75, -120)
16+
$okButton.Size = New-Object System.Drawing.Size(75,23)
17+
$okButton.Text = 'OK'
18+
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
19+
$form.AcceptButton = $okButton
20+
$form.Controls.Add($okButton)
21+
22+
$label = New-Object System.Windows.Forms.Label
23+
$label.Location = New-Object System.Drawing.Point(10, 15)
24+
$label.Size = New-Object System.Drawing.Size($($width - 25), 20)
25+
$label.Text = '选择要执行的脚本'
26+
$form.Controls.Add($label)
27+
28+
$listBox = New-Object System.Windows.Forms.ListBox
29+
$listBox.Location = New-Object System.Drawing.Point(10, 40)
30+
$listBox.Size = New-Object System.Drawing.Size($($width - 35), $($height - 90))
31+
32+
foreach($property in $scrips.psobject.properties.name)
33+
{
34+
$item = $listBox.Items.Add($property);
35+
}
36+
37+
$form.Controls.Add($listBox)
38+
39+
$form.Topmost = $true
40+
$result = $form.ShowDialog()
41+
42+
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
43+
{
44+
& npm run $listBox.SelectedItem
45+
}
46+
}

shell/internal/package1.reg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Windows Registry Editor Version 5.00
2+
3+
;右键菜单项1, 执行脚本, 显示cmd窗口
4+
[HKEY_CLASSES_ROOT\Directory\Background\shell\ps_npm_scripts]
5+
@="执行NPM脚本(&M)"
6+
"Icon"="powershell.exe"
7+
8+
[HKEY_CLASSES_ROOT\Directory\Background\shell\ps_npm_scripts\command]
9+
;注意: 这里的路径需要修改成脚本所在的路径↓↓
10+
@="cmd.exe /C PowerShell.exe -file \"E:\\web\\command-manager\\shell\\internal\\package1.ps1\""

0 commit comments

Comments
 (0)