我正在尝试创建一个脚本,用于从锥体中的快捷方式导入任务。它与注册表一起使用,但我想有一个更通用的解决方案。我没有找到命令提示符开关或API来添加任务。或区分conmumu在哪里存储设置的方法。
有没有?这是一个脚本示例
Param(
[string]$path
)
$ErrorActionPreference = "Stop"
function Get-ShortCut($filePath)
{
$shell = New-Object -COM WScript.Shell
$shell.CreateShortcut($filePath)
}
$shortcut = Get-ShortCut $path
function Add-ShortcutToConEmu($shortcut)
{
$tasksPath = "HKCU:\Software\ConEmu\.Vanilla\Tasks"
$max = [int]((Get-ItemProperty -Path $tasksPath -Name "Count").Count)
$newCount = $max + 1
$keyPath = "$tasksPath\Task$newCount"
New-Item -Path $keyPath -Force
New-ItemProperty -Path $keyPath -Name "Active" -Value 0 -PropertyType DWord
New-ItemProperty -Path $keyPath -Name "Cmd1" -Value "-new_console:d:`"$($shortcut.WorkingDirectory)`" `"$($shortcut.TargetPath)`" $($shortcut.Arguments)" -PropertyType String
New-ItemProperty -Path $keyPath -Name "Count" -Value 1 -PropertyType Dword
New-ItemProperty -Path $keyPath -Name "Flags" -Value 4 -PropertyType DWord
New-ItemProperty -Path $keyPath -Name "GuiArgs" -Value "/icon `"$($shortcut.IconLocation)`"" -PropertyType String
New-ItemProperty -Path $keyPath -Name "Hotkey" -Value 0 -PropertyType DWord
New-ItemProperty -Path $keyPath -Name "Name" -Value (Split-Path $shortcut.FullName -Leaf) -PropertyType String
Set-ItemProperty -path $tasksPath -Name "Count" -Value $newCount
}
$shortcut.FullName
Add-ShortcutToConEmu($shortcut)