3

I have one PowerShell script test.ps1 and I am trying to execute it from a test.bat file. My batch file contains:

@echo off
Powershell.exe -File D:\Testfolder\testsubfolder\test.ps1
pause

And I am getting the error:

'■@' is not recognized as an internal or external command, operable program or batch file.

Can someone point out what change I should make to run it correctly?

3
  • Can you post the code please Commented Nov 30, 2016 at 9:55
  • 3
    This looks like an encoding problem. To debug it, you should consider creating a MCVE. Commented Nov 30, 2016 at 10:27
  • Include a hexdump of the first couple bytes of the script file. Commented Nov 30, 2016 at 10:43

1 Answer 1

3
  1. Rename your batch file to a .txt format
  2. Open the file in Notepad
  3. Change the Encoding to ANSI using the Save As method (encoding will be at the bottom of the save file window)
  4. Save the file again and rename it back to a .bat format
Sign up to request clarification or add additional context in comments.

2 Comments

it worked @Random206, actually i copied the old bat file and updated the script inside it, when i created new file as you suggested it worked. thank you
No problems, happy to help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.