Invisible, non existent character blocking running a cmd file when changing text content through PowerShell
'■s' is not recognized as an internal or external command, operable program or batch file.
The file would immediately open and close when I tried to open it normally, I decided to go into CMD and try to open it through there so see the issue, it came out with what is shown above.
I decided to make a completely identical file, copy pasted everything over and it worked just fine. The properties of the file show zero extra bytes vs the remade one.
https://www.dropbox.com/s/yv66vrb5p0l76u6/end.bat?dl=0
Here's a file with the issue, feel free to mess with it.
powershell cmd
add a comment |
'■s' is not recognized as an internal or external command, operable program or batch file.
The file would immediately open and close when I tried to open it normally, I decided to go into CMD and try to open it through there so see the issue, it came out with what is shown above.
I decided to make a completely identical file, copy pasted everything over and it worked just fine. The properties of the file show zero extra bytes vs the remade one.
https://www.dropbox.com/s/yv66vrb5p0l76u6/end.bat?dl=0
Here's a file with the issue, feel free to mess with it.
powershell cmd
1
At first glance, this looks like an encoding issue. Try changing it to CP437, remove the faulty character that now appears, and run it again.
– Florian
Nov 26 '18 at 9:26
1
save you file with coding "ANSI", not "Unicode". (Unicode is the default for notepad, if you didn't change it) Unicode characters are two bytes for each character, cmd can't read that properly.
– Stephan
Nov 26 '18 at 10:09
2
Depending on how your unknown PowerShell code writes to file it might need a parameter -Enccoding ascii / default / oem
– LotPings
Nov 26 '18 at 12:15
Inspect the file with a hex editor (e.g. HxD) to see its raw content.
– Ansgar Wiechers
Nov 26 '18 at 12:32
Non-answer i know, but: Any reason the file isn't just powershell being executed instead of .bat ? it can do all the same stuff and more.
– Jim Wolff
Nov 26 '18 at 12:37
add a comment |
'■s' is not recognized as an internal or external command, operable program or batch file.
The file would immediately open and close when I tried to open it normally, I decided to go into CMD and try to open it through there so see the issue, it came out with what is shown above.
I decided to make a completely identical file, copy pasted everything over and it worked just fine. The properties of the file show zero extra bytes vs the remade one.
https://www.dropbox.com/s/yv66vrb5p0l76u6/end.bat?dl=0
Here's a file with the issue, feel free to mess with it.
powershell cmd
'■s' is not recognized as an internal or external command, operable program or batch file.
The file would immediately open and close when I tried to open it normally, I decided to go into CMD and try to open it through there so see the issue, it came out with what is shown above.
I decided to make a completely identical file, copy pasted everything over and it worked just fine. The properties of the file show zero extra bytes vs the remade one.
https://www.dropbox.com/s/yv66vrb5p0l76u6/end.bat?dl=0
Here's a file with the issue, feel free to mess with it.
powershell cmd
powershell cmd
edited Nov 26 '18 at 12:31
Ansgar Wiechers
146k13132190
146k13132190
asked Nov 26 '18 at 9:06
skysky
82
82
1
At first glance, this looks like an encoding issue. Try changing it to CP437, remove the faulty character that now appears, and run it again.
– Florian
Nov 26 '18 at 9:26
1
save you file with coding "ANSI", not "Unicode". (Unicode is the default for notepad, if you didn't change it) Unicode characters are two bytes for each character, cmd can't read that properly.
– Stephan
Nov 26 '18 at 10:09
2
Depending on how your unknown PowerShell code writes to file it might need a parameter -Enccoding ascii / default / oem
– LotPings
Nov 26 '18 at 12:15
Inspect the file with a hex editor (e.g. HxD) to see its raw content.
– Ansgar Wiechers
Nov 26 '18 at 12:32
Non-answer i know, but: Any reason the file isn't just powershell being executed instead of .bat ? it can do all the same stuff and more.
– Jim Wolff
Nov 26 '18 at 12:37
add a comment |
1
At first glance, this looks like an encoding issue. Try changing it to CP437, remove the faulty character that now appears, and run it again.
– Florian
Nov 26 '18 at 9:26
1
save you file with coding "ANSI", not "Unicode". (Unicode is the default for notepad, if you didn't change it) Unicode characters are two bytes for each character, cmd can't read that properly.
– Stephan
Nov 26 '18 at 10:09
2
Depending on how your unknown PowerShell code writes to file it might need a parameter -Enccoding ascii / default / oem
– LotPings
Nov 26 '18 at 12:15
Inspect the file with a hex editor (e.g. HxD) to see its raw content.
– Ansgar Wiechers
Nov 26 '18 at 12:32
Non-answer i know, but: Any reason the file isn't just powershell being executed instead of .bat ? it can do all the same stuff and more.
– Jim Wolff
Nov 26 '18 at 12:37
1
1
At first glance, this looks like an encoding issue. Try changing it to CP437, remove the faulty character that now appears, and run it again.
– Florian
Nov 26 '18 at 9:26
At first glance, this looks like an encoding issue. Try changing it to CP437, remove the faulty character that now appears, and run it again.
– Florian
Nov 26 '18 at 9:26
1
1
save you file with coding "ANSI", not "Unicode". (Unicode is the default for notepad, if you didn't change it) Unicode characters are two bytes for each character, cmd can't read that properly.
– Stephan
Nov 26 '18 at 10:09
save you file with coding "ANSI", not "Unicode". (Unicode is the default for notepad, if you didn't change it) Unicode characters are two bytes for each character, cmd can't read that properly.
– Stephan
Nov 26 '18 at 10:09
2
2
Depending on how your unknown PowerShell code writes to file it might need a parameter -Enccoding ascii / default / oem
– LotPings
Nov 26 '18 at 12:15
Depending on how your unknown PowerShell code writes to file it might need a parameter -Enccoding ascii / default / oem
– LotPings
Nov 26 '18 at 12:15
Inspect the file with a hex editor (e.g. HxD) to see its raw content.
– Ansgar Wiechers
Nov 26 '18 at 12:32
Inspect the file with a hex editor (e.g. HxD) to see its raw content.
– Ansgar Wiechers
Nov 26 '18 at 12:32
Non-answer i know, but: Any reason the file isn't just powershell being executed instead of .bat ? it can do all the same stuff and more.
– Jim Wolff
Nov 26 '18 at 12:37
Non-answer i know, but: Any reason the file isn't just powershell being executed instead of .bat ? it can do all the same stuff and more.
– Jim Wolff
Nov 26 '18 at 12:37
add a comment |
1 Answer
1
active
oldest
votes
Powershell could be writing an extra BOM if you are adding one aswell, since .net (which powershell runs) handles that under the hood, this is a scenario that sometimes happens.
You can sometimes get into trouble when generating text files in unicode, because some mechanism might handle BOM and some might want you to handle it, or 2 steps both "handle" adding the BOM, ending up with 2 of them.
You can check the file in a hex editor and see if it starts with FEFF twice instead of once.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477737%2finvisible-non-existent-character-blocking-running-a-cmd-file-when-changing-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Powershell could be writing an extra BOM if you are adding one aswell, since .net (which powershell runs) handles that under the hood, this is a scenario that sometimes happens.
You can sometimes get into trouble when generating text files in unicode, because some mechanism might handle BOM and some might want you to handle it, or 2 steps both "handle" adding the BOM, ending up with 2 of them.
You can check the file in a hex editor and see if it starts with FEFF twice instead of once.
add a comment |
Powershell could be writing an extra BOM if you are adding one aswell, since .net (which powershell runs) handles that under the hood, this is a scenario that sometimes happens.
You can sometimes get into trouble when generating text files in unicode, because some mechanism might handle BOM and some might want you to handle it, or 2 steps both "handle" adding the BOM, ending up with 2 of them.
You can check the file in a hex editor and see if it starts with FEFF twice instead of once.
add a comment |
Powershell could be writing an extra BOM if you are adding one aswell, since .net (which powershell runs) handles that under the hood, this is a scenario that sometimes happens.
You can sometimes get into trouble when generating text files in unicode, because some mechanism might handle BOM and some might want you to handle it, or 2 steps both "handle" adding the BOM, ending up with 2 of them.
You can check the file in a hex editor and see if it starts with FEFF twice instead of once.
Powershell could be writing an extra BOM if you are adding one aswell, since .net (which powershell runs) handles that under the hood, this is a scenario that sometimes happens.
You can sometimes get into trouble when generating text files in unicode, because some mechanism might handle BOM and some might want you to handle it, or 2 steps both "handle" adding the BOM, ending up with 2 of them.
You can check the file in a hex editor and see if it starts with FEFF twice instead of once.
answered Nov 26 '18 at 12:44
Jim WolffJim Wolff
3,37742437
3,37742437
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477737%2finvisible-non-existent-character-blocking-running-a-cmd-file-when-changing-text%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
At first glance, this looks like an encoding issue. Try changing it to CP437, remove the faulty character that now appears, and run it again.
– Florian
Nov 26 '18 at 9:26
1
save you file with coding "ANSI", not "Unicode". (Unicode is the default for notepad, if you didn't change it) Unicode characters are two bytes for each character, cmd can't read that properly.
– Stephan
Nov 26 '18 at 10:09
2
Depending on how your unknown PowerShell code writes to file it might need a parameter -Enccoding ascii / default / oem
– LotPings
Nov 26 '18 at 12:15
Inspect the file with a hex editor (e.g. HxD) to see its raw content.
– Ansgar Wiechers
Nov 26 '18 at 12:32
Non-answer i know, but: Any reason the file isn't just powershell being executed instead of .bat ? it can do all the same stuff and more.
– Jim Wolff
Nov 26 '18 at 12:37