0

Is it possible to run an UltraEdit macro or script from the PowerShell? Something like following:

uedit64.exe c:\temp\test.txt /s,e="c:\temp\script.js"

I have nothing special. I just want to open the log file with UltraEdit and as soon the log file is opened the UltraEdit Script should be executed on that. The following code opens the log file but does not execute the script on that.

$ultraEdit = "C:\...\UltraEdit\uedit64.exe"
$logFile = "C:\...\res.log"
$scriptFile = "C:\...\ultraEditScript.js"

Start-Process -FilePath $ultraEdit -ArgumentList "$logFile /s=`"$scriptFile`""
Sherzad
  • 405
  • 4
  • 14
  • Have a look at `Start-Process` and its [examples at the bottom](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process?view=powershell-6#examples) – DarkLite1 Mar 29 '19 at 13:21
  • I already looked at the documentation but could not figure it out how to open a file with Ultraedit and run a script on that file. I need this with PowerShell "https://www.ultraedit.com/support/tutorials-power-tips/ultraedit/run-macro-script-from-command-line.html" – Sherzad Mar 29 '19 at 13:33

3 Answers3

1

Absolutely! Powershell has a few different "call" operators. https://ss64.com/ps/call.html

Take a look at the documentation for Start-process. https://learn.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`""

Should work for you (change the path of course.

0

Yes, it is possible. The problem with your current example is surrounding quoting rules with arguments:

uedit64.exe c:\temp\test.txt '/s,e="c:\temp\script.js"'

This form should work. When you use commas, 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 's interpretation, but note this falls back to the parser on Windows:

#requires -Version 3
uedit64.exe --% C:\Temp\test.txt /s,e="C:\Temp\script.js"

What the difference in parsers means is that you can't expand variables (if you wanted $path\script.js) in the arguments after the stop-parser, but you can still utilize environment variables using the batch syntax %VAR%.

As a best-practice, it's recommended to fully-qualify your path and use the call operator for clarity:

& C:\Temp\uedit64.exe
Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63
0

Thanks everyone, The problem was with Select-String that split the matched lines, therefore, the script did not perform any action due to improper file structure.

These two works great :-)

1. & $ultraEdit /fni $logFile /S=$scriptFile

2. Start-Process -FilePath $ultraEdit -ArgumentList "$logFile /S=$scriptFile"
Sherzad
  • 405
  • 4
  • 14