Don't succeed to execute .exe using powershell

时间:2016-11-09 06:51:16

标签: powershell

I've looked into the forum for one hour now, and tried everything I've found here but still I don't manage to run my .exe using a powershell script.
Please forgive my ignorance, I'm very new with powershell..

Basically, my script is aimed to daily monitor files loaded.
For this, I need to list .txt files in my working directory, which I managed to do.
My issue is that when files arrive in my working folder, they have nonspeaking names that I can't figure out which business it's related to.
There is a RemaneFile1.exe executable that renames files according to some data codes inside my .txt files from something like "Inf320638.txt" to something like "lot_RUHPEG_296_320638" and that is exactly what .exe I would like to run using powershell (I didn't coded it, and I don't know how it works, just that when I manually run it it renames my files just fine).

I've tried those two command lines below, but when I look at my files, they are actually not renamed. 1. &".\INFOCENTRE\LOTS\RenameFile1.exe => When I check my file name it's still like "Inf320638.txt".
2. Start-Process ".\INFOCENTRE\LOTS\RenameFile1.exe" => A command prompt shows up for an instant, but when I check my file name it's like "Inf320638.txt".

Any help would be highly appreciated,

Brgs, Thomas.

1 个答案:

答案 0 :(得分:0)

尝试使用以下参数运行可执行文件:

Start-Process .\INFOCENTRE\LOTS\RenameFile1.exe -WorkingDirectory .\INFOCENTRE\LOTS -Wait

可能是,工作目录是搞砸了。 -wait开关让powershell等待程序完成,你可以省略它。