如何在上下文菜单Windows中执行带有文件名的make?

时间:2019-06-12 16:28:41

标签: windows batch-file makefile registry

我想知道如何在Windows上下文菜单中将文件名传递给make命令。

我设法做到了

function Get-MsiProductCode {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        [ValidateScript({$_ | Test-Path -PathType Leaf})]
        [string]$Path
    )

    function Get-Property ( $Object, $PropertyName, [object[]]$ArgumentList ) {
        return $Object.GetType().InvokeMember($PropertyName, 'Public, Instance, GetProperty', $null, $Object, $ArgumentList)
    }

    function Invoke-Method ( $Object, $MethodName, $ArgumentList ) {
        return $Object.GetType().InvokeMember( $MethodName, 'Public, Instance, InvokeMethod', $null, $Object, $ArgumentList )
    }

    $ErrorActionPreference = 'Stop'
    Set-StrictMode -Version Latest

    #http://msdn.microsoft.com/en-us/library/aa369432(v=vs.85).aspx
    $msiOpenDatabaseModeReadOnly = 0
    $Installer = New-Object -ComObject WindowsInstaller.Installer

    $Database = Invoke-Method $Installer OpenDatabase $Path, $msiOpenDatabaseModeReadOnly

    $View = Invoke-Method $Database OpenView "SELECT Value FROM Property WHERE Property='ProductCode'"

    [void]( Invoke-Method $View Execute )

    $Record = Invoke-Method $View Fetch
    if ( $Record ) {
        Get-Property $Record StringData 1
    }

    [void]( Invoke-Method $View Close @() )
    Remove-Variable -Name Record, View, Database, Installer
}

效果很好。但是做这样的事情根本行不通

[HKEY_CLASSES_ROOT\Directory\Background\shell\cygwin_bash_mi\command]
@="D:\\cygwin\\bin\\bash.exe -c 'make install'"

我什至试图将%1更改为%〜nx1和%〜nxI,但是它也不起作用。 有解决办法吗?

0 个答案:

没有答案