Copy link to clipboard
Copied
Has anyone been able to invoke powershell commands using system.callSystem()?
Here's what I've tried
var response = system.callSystem("powershell.exe /command \"& { gci }\"");
alert(response);
if I try the command from cmd or the windows-r run command thingy I get a directory listing—as expected, but from extendscript I get nothing. I've tried all sorts of variations. Or is cmd the only shell that can be run from system.callSystem()?
No amount of quoting, escaping or putting inside of braces and brackets will convince powershell to run from callSystem() for me.
What does work is calling cmd, then making powershell the command that cmd runs. Kludgy, but then what did I expect?
e.g.:
system.callSystem("cmd.exe /c powershell.exe -c \"doSome-Powershell -magic $here\"");
You can't return a value from the powershell command though, you have to save the output to a temporary file and read that in the script.
Here's a real example that c
...Copy link to clipboard
Copied
Strange, I'm seeing the same issue... Are you using a CEP Panel by chance? If so you can achieve this with:
var execSync = require('child_process').execSync;
execSync("powershell.exe /command \"& { gci }\"", {encoding:'UTF-8'});
Copy link to clipboard
Copied
no, just scriptUI. I can't get CEP panels to work.
Copy link to clipboard
Copied
No amount of quoting, escaping or putting inside of braces and brackets will convince powershell to run from callSystem() for me.
What does work is calling cmd, then making powershell the command that cmd runs. Kludgy, but then what did I expect?
e.g.:
system.callSystem("cmd.exe /c powershell.exe -c \"doSome-Powershell -magic $here\"");
You can't return a value from the powershell command though, you have to save the output to a temporary file and read that in the script.
Here's a real example that collects all the available system fonts (because Adobe haven't seen fit to make this available to scripters in AE like it is in Photoshop or Illustrator):
system.callSystem("cmd.exe /c powershell.exe -c \"[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing');set-content fontlist.json (convertTo-json(New-Object System.Drawing.Text.InstalledFontCollection))\"");
That saves a file called fontlist.json to the folder where the script is run from. You then have to parse it in extendscript to get the available fonts.
Copy link to clipboard
Copied
What kind of font data do you need? If it's just the list of font names, you can do this just in ExtendScript:
var fontFolder = new Folder('C:\\WINDOWS\\Fonts');
var fonts = fontFolder.getFiles();