| 1. |
Solve : Please test this batch script.? |
|
Answer» The script uses Extended ASCII codes and I want to determine if the default codes differ across Windows systems especially Vista and Win 7 variants. (a) Copy the script to your clipboard. command.com -> edit.com -> pasted -> saved as bat script (1) run in command.com (command window font set to 7x12 raster font) (2) same batch run in cmd.exe (7 x 12 raster font) Quote from: Dusty on December 25, 2009, 01:21:03 PM I have found that the Extended Ascii codes are changed when the script is pasted into Edit.com running in Cmd.exe so the output there is not what is wanted, but, when the script is pasted into Edit.com running in Command.com the codes are properly pasted and the output is aok. cmd supports- or tries to support, unicode. command.com does not. Either way, you cannot run edit.com from within cmd; it spawns command.com to run it anyway, not sure exactly where the issue lies, but I assure you it has to do with unicode/ANSI support. If you save as ANSI encoded in any text editor your batch will work (given that the fonts match)Salmon Trout - Thank you again, that's exactly what I was trying to replicate. BC-P - sorry, I'm not sure what you mean. Quote If you save as ANSI encoded in any text editor your batch will work (given that the fonts match) It's been shown that attempting to save the script using Notepad brings up the warning shown below even when Ansi encoding is selected. Selecting Unicode MAKES the script unusable. Quote from: Salmon Trout on December 25, 2009, 03:29:24 AM Finally I saved it from Notepad as dt4.bat with ANSI encoding and it ran fine, just like the screen capture I posted above.Quote from: BC_Programmer on December 25, 2009, 06:36:30 PM Quote from: Salmon TroutFinally I saved it from Notepad as dt4.bat with ANSI encoding and it ran fine, just like the screen capture I posted above. Yeah, sure, the script runs but does not produce the REQUIRED output because the Extended Ascii chars have changed as shown in Salmon Trout's screen capture in reply #3. After saving the copy/post into Edit.com running in Command.com the script runs correctly and produces the required output as shown in Salmon Trout's reply #5. Thank you for your interest, would you run the script in Vista and post your results please? Quote from: Dusty on December 25, 2009, 10:01:12 PM Yeah, sure, the script runs but does not produce the required output because the Extended Ascii chars have changed as shown in Salmon Trout's screen capture in reply #3. none of the character codes were changed. Quote I am using Consolas as my console window font. (Not every console font has the same characters above ASCII 127.) and then, in the later screenshots: Quote (command window font set to 7x12 raster font) this is the key. Anyway, I ran it on mine, and even though I was using Raster fonts, I still got the same characters as Salmon Trout: I decided to investigate. the issue is rooted solely in code pages. When I visited character map and went to the code that corresponded to the character I saw, it was there, within the same set of fonts. under the same code. This was odd. BUT! I changed the "character" in character maps "advanced" section to "DOS-US" and the line drawing characters were there. Since I'm on Vista x64 I cannot run edit and it isn't included with my OS. I was able to get agreeable results by "cheating" what I did, was I copied the batch file to the clipboard, used the command "copy con D:\test.bat" and used the cmd "paste" feature, followed by Control-Z and enter. I did end up with an extra @echo off line at the top, but it has no impact on the functionality. I ran the batch resulting from this, and success!: So it works, as long as the batch os created properly, in vista x64. As it is now, there are a LOT of encoding conversions to get it on other machines, copy from browser, paste to editor, etc. So, I decided to simply plop it in a text file and attach it as is. this way, the file should be relatively untainted by any data manipulation performed by the OS during copy paste, and it will be easier for others using other operating systems to test... in fact... test on my win 7 laptop: Note: these are both x64 systems; I'd imagine it will work fine on x86 versions of these Operating Systems, too. [Saving SPACE, attachment deleted by admin]BC_P - thank you, the results you produced are greatly appreciated. D.. |
|