PowerShell 运行 Ultraedit 脚本
PowerShell run Ultraedit Script
是否可以从 PowerShell 运行 UltraEdit 宏或脚本?类似以下内容:
uedit64.exe c:\temp\test.txt /s,e="c:\temp\script.js"
我没什么特别的。我只想用 UltraEdit 打开 日志文件 并且一旦 日志文件 打开 UltraEdit应该在上面执行脚本。以下代码打开日志文件但不执行上面的脚本。
$ultraEdit = "C:\...\UltraEdit\uedit64.exe"
$logFile = "C:\...\res.log"
$scriptFile = "C:\...\ultraEditScript.js"
Start-Process -FilePath $ultraEdit -ArgumentList "$logFile /s=`"$scriptFile`""
当然! Powershell 有几个不同的 "call" 运算符。
https://ss64.com/ps/call.html
查看 Start-process 的文档。
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-6
Start-Process -FilePath "c:\pathtoexe\uedit64.exe" -ArgumentList "c:\temp\test.txt /s,e=`"c:\temp\script.js`""
应该适合你(当然改变路径。
是的,这是可能的。您当前示例的问题是围绕带参数的引用规则:
uedit64.exe c:\temp\test.txt '/s,e="c:\temp\script.js"'
此表格应该有效。当您使用逗号时,Windows:
上的 powershell will interpret that as an array. The safest way to pass arguments to an external executable is to use the stop-parser operator (--%
) to avoid powershell's interpretation, but note this falls back to the cmd 解析器
#requires -Version 3
uedit64.exe --% C:\Temp\test.txt /s,e="C:\Temp\script.js"
解析器的不同之处在于您不能在停止解析器之后的参数中扩展变量(如果您想要 $path\script.js
),但您仍然可以使用批处理语法 %VAR%
.
作为最佳实践,建议完全限定您的路径并使用调用运算符以确保清晰度:
& C:\Temp\uedit64.exe
谢谢大家,
问题是 Select-String 分割了匹配的行,因此,由于文件结构不正确,脚本没有执行任何操作。
这两个作品很棒:-)
1. & $ultraEdit /fni $logFile /S=$scriptFile
2. Start-Process -FilePath $ultraEdit -ArgumentList "$logFile /S=$scriptFile"
是否可以从 PowerShell 运行 UltraEdit 宏或脚本?类似以下内容:
uedit64.exe c:\temp\test.txt /s,e="c:\temp\script.js"
我没什么特别的。我只想用 UltraEdit 打开 日志文件 并且一旦 日志文件 打开 UltraEdit应该在上面执行脚本。以下代码打开日志文件但不执行上面的脚本。
$ultraEdit = "C:\...\UltraEdit\uedit64.exe"
$logFile = "C:\...\res.log"
$scriptFile = "C:\...\ultraEditScript.js"
Start-Process -FilePath $ultraEdit -ArgumentList "$logFile /s=`"$scriptFile`""
当然! Powershell 有几个不同的 "call" 运算符。 https://ss64.com/ps/call.html
查看 Start-process 的文档。 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-6
Start-Process -FilePath "c:\pathtoexe\uedit64.exe" -ArgumentList "c:\temp\test.txt /s,e=`"c:\temp\script.js`""
应该适合你(当然改变路径。
是的,这是可能的。您当前示例的问题是围绕带参数的引用规则:
uedit64.exe c:\temp\test.txt '/s,e="c:\temp\script.js"'
此表格应该有效。当您使用逗号时,Windows:
上的 powershell will interpret that as an array. The safest way to pass arguments to an external executable is to use the stop-parser operator (--%
) to avoid powershell's interpretation, but note this falls back to the cmd 解析器
#requires -Version 3
uedit64.exe --% C:\Temp\test.txt /s,e="C:\Temp\script.js"
解析器的不同之处在于您不能在停止解析器之后的参数中扩展变量(如果您想要 $path\script.js
),但您仍然可以使用批处理语法 %VAR%
.
作为最佳实践,建议完全限定您的路径并使用调用运算符以确保清晰度:
& C:\Temp\uedit64.exe
谢谢大家, 问题是 Select-String 分割了匹配的行,因此,由于文件结构不正确,脚本没有执行任何操作。
这两个作品很棒:-)
1. & $ultraEdit /fni $logFile /S=$scriptFile
2. Start-Process -FilePath $ultraEdit -ArgumentList "$logFile /S=$scriptFile"