1

My script is moving files from one directory to another, once it is done moving the files it then launches a program. I can launch the program from the short cut, I can launch it from .cmd, but when I have Powershell run it I get an error.
"The following error occured initializing the program:
Error accessing file: Conf/logging.properties
The program will now exit."

I only get this error from Powershell.

I've tried the following but none have worked.

 & C:\SMT\App\SMT.exe
 & C:\SMT\App\SMT_Start.cmd
 start-process "cmd.exe" "/c C:\SMT\App\SMT_Start.cmd"

the cmd file works when double clicked, looks like:

 start C:\SMT\App\SMT.exe -clean

The short cut properties look like:
Target: C:\SMT\App\SMT.exe -clean
Start in: C:\SMT\App
Any ideas?

1 Answer 1

1

You could have this as a complete PowerShell solution. I think that -WorkingDirectory is what you need.

Start-Process -FilePath "C:\SMT\App\SMT.exe" -WorkingDirectory "C:\SMT\App" -ArgumentList "-clean" -Wait

You can use the -WorkingDirectory to ensure the "Start In:" and -ArgugmentList for the parameter -clean that you are passing. -Wait to not continue processing until the command is complete. This depends if the exe closes on its own or not. Experiment with the presence of that switch.

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

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.