views:

473

answers:

1

Hi all!

I have a third-party application that's extensible by adding exe-files that perform dataconversion etc. I've written an extension in Powershell that does the conversion I want, but I'm unable to get the third-party app to run my ps1, as it will only accept an .exe file as an extension. The app adds a filename as the first (and only) commandline argument to the extension, so the command it runs looks like:

someprogram.exe somefile.xml

I tried to get it to run Powershell.exe with my script as an argument, but I haven't been able to figure out how and if that's possible. Some stuff I tried like

powershell.exe myscript.ps1

won't work. I tried getting the script to find the correct XML file itself, but still somehow I couldn't get Powershell to run off the commandline and take a script as an argument and run it.

Next I thought about writing a small .exe file that only runs the Powershell script, but is that even possible? If it is, could someone nudge me in the right direction?

+1  A: 

Powershell wants to have a qualified path to script files before it will run them. So you need to either use

powershell.exe .\myscript.ps1

if it lies in the current working directory (unlikely and prone to break for this use case) or use the full path to the script:

powershell.exe C:\Users\Foo\Scripts\myscript.ps1

or similar.

Joey
Yes, I was aware of that, but it seems my app was unable to cope with this. I'll try it again, just to make sure, but I'm pretty sure that the commandline argument wasn't passed when I went this route....
tplive