I can not get a powershell script to execute a bat file directly. For example, this works on the command line:
.\\my-app\my-fle.bat
When I add this command to a script, it outputs:
The term '.\\my-app\my-file.bat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I also tried the following, with the same result:
& .\\my-app\my-fle.bat & ".\\my-app\my-fle.bat" \my-app\my-fle.bat & \my-app\my-fle.bat & "\my-app\my-fle.bat"
Note: It must return the lastexitcode as I need to verify success of batch.
Unlike an executable file, a batch file can be opened in any text editor, making it easy to copy or modify. To protect the contents of your batch file, you must encrypt it using the native Windows 7 Encrypting File System.
BAT files are most commonly used to start programs and run maintenance utilities within Windows. The danger: A BAT file contains a series of line commands that will run if it is opened, which makes it a good option for malicious programmers.
cmd.exe /c '\my-app\my-file.bat'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With