Reputation: 7445
When I execute .\flyway.cmd
from a PowerShell, it behaves as I'd expect - output stays in powershell. However, when I run c:\temp\flyway\flyway.cmd
(absolute path), it pops open a cmd window instead. Why?
Additional info: Inspired by the question of "What's in the CMD script?" from andyb, I started playing around with different scripts. I eventually found that I can make an exact copy of the current cmd file and that copy runs as expected. This means there's something about the file attributes that is making it do this. It was originally a "blocked" file which I had to unblock in it's properties (windows often does this with files that were downloaded). But it isn't any longer. I can also make it run consistently by running the whole command with cmd /c, but that still doesn't explain what is different.
Upvotes: 0
Views: 1580
Reputation: 146
I think it's due to how PS interprets ".\" For PS, that means you're going to run something. Putting the absolute path to a file, means you're referencing the file as you would from the Windows Explorer.
If you want to run it using an absolute path, use the call operator "&":
& 'c:\temp\flyway\flyway.cmd'
That should do the trick.
You can read more about it on TechNet or The PowerShell Wiki
I hope this helps you!
Happy scripting!
Upvotes: 2