0

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
  • I think you need clarify what you mean by "won't work". Is there an error message? What happens when you try to run it yourself, say through the Run dialog? Commented Jun 5, 2009 at 18:51

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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....
0

You can also try Powershell.exe -Command "& your-app.exe ${your-arguments}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.