International FORMAT "Y"
#1
Posted 06 October 2007 - 04:12 PM
(for those who didn't see it is a batch to manage MBR's on "real" and "virtual" disks, MKIMG will create and format a HD image of given size/geometry/filesystem)
In the process, I mount the image with VDK and FORMAT it, there is no problem in "interactive" mode, but to make possible to use it as batch with no user intervention I need to "feed" a "Y" (in English) to FORMAT. Besides, I need to use in "interactive mode" the /P switch of DEL to require user confirmation for the deletion of two files, and omit it in "batch" mode.The code is like this:
[codebox].... SET Noprompts=%5 .... IF NOT DEFINED NoPrompts SET PDEL=/P&SET PFormat=FORMAT FOR %%A IN (o y s) DO IF /I %NoPrompts:~1,2%.==%%A. (SET PDEL=&SET PFormat=echo %%A^| FORMAT ) ELSE (SET PDEL=/P&SET PFormat=FORMAT &SET Noprompts=) .... %Pformat% %Drive% /FS:%Filesystem% /Q /V:NO_NAME[/codebox] The effect, given that image is mounted as J: and filesystem is FAT is (on English System): in "interactive" mode: [code]FORMAT J: /FS;FAT /Q /V:NO_NAME[/code] (user is prompted to confirm) in "batch" mode: [code]ECHO Y | FORMAT J: /FS;FAT /Q /V:NO_NAME[/code]
(format goes on without user intervention)
For now I have:
S for Sì (Italian)
O for Oui (French)
Y for yes (English)
I could well put in the FOR list all letters, in order to let the user use the one he normally uses with his national version of the FORMAT command, but the "narrower" the list is the less prone to problems, and besides it would be nice if I could provide in the docs a list of accepted switches ordered by nations.
Any contribution will be appreciated.
jaclaz
#2
Posted 06 October 2007 - 04:57 PM
German is 'J' for 'Ja'I am writing the MKIMG part of my MBRbatch.cmd.
.....
Any contribution will be appreciated.
jaclaz
Peter
#3
Posted 07 October 2007 - 12:28 AM
#4
Posted 07 October 2007 - 12:51 PM
#5
Posted 07 October 2007 - 01:46 PM
Don't forget D for Da, for our russian friends.
Don't Russian users use a cyrillic keyboard and codepage?
i.e. is the character "D" or "д"?
jaclaz
#6
Posted 07 October 2007 - 03:49 PM
as you know, I'm not a friend of hardcoded values or lists.
Therefore here my nativeYes suggestion.
It is just a how-to. I'm sure that you are much more experienced in batches and will optimize my code.
But it brings the 'Yes' character into the file 'yes.txt' for all languages which ask for Yes/No like 'bla bla (Y/N)'
ECHO ? | chkdsk %SystemDrive%/f > result.txt For /f "tokens=2 delims=(" %%l in (result.txt) do echo %%l > result1.txt For /f "tokens=1 delims=/" %%l in (result1.txt) do echo %%l > Yes.txt
Peter
#7
Posted 07 October 2007 - 03:53 PM
Both as far as i know. Russian keyboards always sport both alphabets.Don't Russian users use a cyrillic keyboard and codepage?
i.e. is the character "D" or "д"?
jaclaz
Anyway, the keycode should be the same.
#8
Posted 07 October 2007 - 06:26 PM
Yes, I had thought of something like that, what I usually do is parse the output of "commandx /?", but since the /Y is an undocumented command I didn't think of "provoking a question" to see what the available answers would be, VERY good idea!
I'll see if I can provoke (safely) a question (and answer) using the FORMAT command, very remote possibility, but one could have, say, a German CHKDSK and an English FORMAT.
jaclaz
#9
Posted 07 October 2007 - 07:49 PM
...
ECHO ? | chkdsk %SystemDrive%/f > result.txt For /f "tokens=2 delims=(" %%l in (result.txt) do echo %%l > result1.txt For /f "tokens=1 delims=/" %%l in (result1.txt) do echo %%l > Yes.txt..
Amazing little piece of code..
#10
Posted 08 October 2007 - 07:44 PM
Amazing little piece of code..
And you still have to see mine!
@psc
When and if you have time, can you test this on a German system?:
VDK.EXE RemoveSET Targetpln=testpsc.plnSET PartType=01SET Filesystem=FATVDK.EXE VIEW %Targetpln%ECHO.FOR /F "tokens=1 delims= " %%A in ('VDK.EXE OPEN 0 %Targetpln% /RW^| FIND /I "%PartType%h:"') DO (SET DRIVE=%%A)IF NOT DEFINED DRIVE GOTO :EOFFOR /F "tokens=2,3 delims=(/)" %%A in ('ECHO ? ^| Format %Drive% /FS:%Filesystem% /Q /V:NO_NAME ^| FIND ")? ?"') DO (SET YES_Letter=%%ASET NO_Letter=%%B)ECHO %YES_Letter% is first letter of the word that means "Yes" in your languageECHO %NO_Letter% is first letter of word that means "No" in your languageVDK.EXE RemoveIt only works if the filesystem on the drive (an image in this case) has a RAW filesystem, which is exactly the case I need it for.I am attaching the smallest possible semi-raw image mountable with VDK, and it's .pln descriptor file.
The snippet, the attached files and a copy of VDK.EXE and VDK.SYS should be in the same directory (unless you have VDK.EXE and VDK.SYS already in path).
Thank you in advance.
jaclaz
Attached Files
#11
Posted 08 October 2007 - 07:50 PM
@jaclazAnd you still have to see mine!
@psc
When and if you have time, can you test this on a German system?:VDK.EXE RemoveSET Targetpln=testpsc.plnSET PartType=01SET Filesystem=FATVDK.EXE VIEW %Targetpln%ECHO.FOR /F "tokens=1 delims= " %%A in ('VDK.EXE OPEN 0 %Targetpln% /RW^| FIND /I "%PartType%h:"') DO (SET DRIVE=%%A)IF NOT DEFINED DRIVE GOTO :EOFFOR /F "tokens=2,3 delims=(/)" %%A in ('ECHO ? ^| Format %Drive% /FS:%Filesystem% /Q /V:NO_NAME ^| FIND ")? ?"') DO (SET YES_Letter=%%ASET NO_Letter=%%B)ECHO %YES_Letter% is first letter of the word that means "Yes" in your languageECHO %NO_Letter% is first letter of word that means "No" in your languageVDK.EXE RemoveIt only works if the filesystem on the drive (an image in this case) has a RAW filesystem, which is exactly the case I need it for.I am attaching the smallest possible semi-raw image mountable with VDK, and it's .pln descriptor file.The snippet, the attached files and a copy of VDK.EXE and VDK.SYS should be in the same directory (unless you have VDK.EXE and VDK.SYS already in path).Thank you in advance. :http://www.boot-land.net/forums/index.php?showtopic=3229&pid=22289&st=0&#
Complete Editcheers:
jaclaz
I usually trust you.
Can I do in this case, too?
No danger to format my system drive unintended?
Peter
#12
Posted 09 October 2007 - 08:28 AM
Well, no, for two reasons:
1) the drive letter is determined by the batch from output of VDK.EXE, which also makes sure that the mounted image has a partition entry for a 01 (FAT12) partition
2) a ? is fed to the FORMAT command, no actual formatting is performed, the only exception being if in some language the word that means Yes begins with a question mark, maybe Klingon or Ferengi could use it, but it is highly unprobable that an Earth language does so
The only side effect of this snippet could be if you already have an image running under VDK.EXE, as to make sure no conflicts arise the batch uninstalls VDK.EXE as first step, thus the already running image will be closed.
jaclaz
#13
Posted 09 October 2007 - 09:09 AM
Here the result:@psc
Well, no, for two reasons:
1) the drive letter is determined by the batch from output of VDK.EXE, which also makes sure that the mounted image has a partition entry for a 01 (FAT12) partition
2) a ? is fed to the FORMAT command, no actual formatting is performed, the only exception being if in some language the word that means Yes begins with a question mark, maybe Klingon or Ferengi could use it, but it is highly unprobable that an Earth language does so
The only side effect of this snippet could be if you already have an image running under VDK.EXE, as to make sure no conflicts arise the batch uninstalls VDK.EXE as first step, thus the already running image will be closed.
jaclaz
C:\scratch\Vdk>VDK.EXE Remove Virtual Disk Driver for Windows version 3.1[url="http://chitchat.at.infoseek.co.jp/vmware/"][url="http://chitchat.at.infoseek.co.jp/vmware/"][url="http://chitchat.at.infoseek.co.jp/vmware/"]http://chitchat.at.infoseek.co.jp/vmware/[/url][/url][/url]The Virtual Disk Driver is not installed.C:\scratch\Vdk>SET Targetpln=testpsc.pln C:\scratch\Vdk>SET PartType=01 C:\scratch\Vdk>SET Filesystem=FAT C:\scratch\Vdk>VDK.EXE VIEW testpsc.pln Virtual Disk Driver for Windows version 3.1[url="http://chitchat.at.infoseek.co.jp/vmware/"][url="http://chitchat.at.infoseek.co.jp/vmware/"][url="http://chitchat.at.infoseek.co.jp/vmware/"]http://chitchat.at.infoseek.co.jp/vmware/[/url][/url][/url]Image Name : testpscDisk Capacity : 2016 sectors (0 MB)Geometry : © 2 * (H) 16 * (S) 63Number Of Files : 1 Type Size Path ------- ------- ---- FLAT 2016 C:\scratch\Vdk\testpsc.imgPartitions : # Start Sector Length in sectors Type -- ------------ --------------------- ---- 0 0 2016 ( 0 MB) 1 63 1953 ( 0 MB) 01h:FAT12C:\scratch\Vdk>ECHO.C:\scratch\Vdk>FOR /F "tokens=1 delims= " %A in ('VDK.EXE OPEN 0 testpsc.pln /RW| FIND /I "01h:"') DO (SET DRIVE=%A ) C:\scratch\Vdk>(SET DRIVE=F: ) C:\scratch\Vdk>IF NOT DEFINED DRIVE GOTO :EOF C:\scratch\Vdk>FOR /F "tokens=2,3 delims=(/)" %A in ('ECHO ? | Format F: /FS:FAT /Q /V:NO_NAME | FIND ")? ?"') DO (SET YES_Letter=%A SET NO_Letter=%B ) C:\scratch\Vdk>(SET YES_Letter=J SET NO_Letter=N ) C:\scratch\Vdk>ECHO J is first letter of the word that means "Yes" in your language J is first letter of the word that means "Yes" in your languageC:\scratch\Vdk>ECHO N is first letter of word that means "No" in your language N is first letter of word that means "No" in your languageC:\scratch\Vdk>VDK.EXE Remove Virtual Disk Driver for Windows version 3.1[url="http://chitchat.at.infoseek.co.jp/vmware/"][url="http://chitchat.at.infoseek.co.jp/vmware/"][url="http://chitchat.at.infoseek.co.jp/vmware/"]http://chitchat.at.infoseek.co.jp/vmware/[/url][/url][/url]Closing the image on the virtual disk 0...The image is closed.Closing the image on the virtual disk 1...The drive is empty.Closing the image on the virtual disk 2...The drive is empty.Closing the image on the virtual disk 3...The drive is empty.Stopped the Virtual Disk Driver.Uninstalled the Virtual Disk Driver.
Peter
#14
Posted 09 October 2007 - 09:21 AM
C:\scratch\Vdk>ECHO J is first letter of the word that means "Yes" in your language
J is first letter of the word that means "Yes" in your language
C:\scratch\Vdk>ECHO N is first letter of word that means "No" in your language
N is first letter of word that means "No" in your language
Well, it works!
Thank you very much for this confirmation and for the suggestion to be "language independent" and to "feed" a ? to commands!
jaclaz
#15
Posted 27 January 2008 - 04:21 PM
D:\IDCS3>VDK.EXE Remove
Virtual Disk Driver for Windows version 3.1
http://chitchat.at.i...k.co.jp/vmware/
The Virtual Disk Driver is not installed.
D:\IDCS3>SET Targetpln=testpsc.pln
D:\IDCS3>SET PartType=01
D:\IDCS3>SET Filesystem=FAT
D:\IDCS3>VDK.EXE VIEW testpsc.pln
Virtual Disk Driver for Windows version 3.1
http://chitchat.at.i...k.co.jp/vmware/
Image Name : testpsc
Disk Capacity : 2016 sectors (0 MB)
Geometry : © 2 * (H) 16 * (S) 63
Number Of Files : 1
Type Size Path
------- ------- ----
FLAT 2016 D:\IDCS3\testpsc.img
Partitions :
# Start Sector Length in sectors Type
-- ------------ --------------------- ----
0 0 2016 ( 0 MB) <disk>
1 63 1953 ( 0 MB) 01h:FAT12
D:\IDCS3>ECHO.
D:\IDCS3>FOR /F "tokens=1 delims= " %A in ('VDK.EXE OPEN 0 testpsc.pln /RW| FIND /I "01h:"') DO (SET DRIVE=%A )
D:\IDCS3>(SET DRIVE=G: )
D:\IDCS3>IF NOT DEFINED DRIVE GOTO :EOF
D:\IDCS3>FOR /F "tokens=2,3 delims=(/)" %A in ('ECHO ? | Format G: /FS:FAT /Q /V:NO_NAME | FIND ")? ?"') DO (
SET YES_Letter=%A
SET NO_Letter=%B
)
D:\IDCS3>ECHO is first letter of the word that means "Yes" in your language
is first letter of the word that means "Yes" in your language
D:\IDCS3>ECHO is first letter of word that means "No" in your language
is first letter of word that means "No" in your language
D:\IDCS3>VDK.EXE Remove
Virtual Disk Driver for Windows version 3.1
http://chitchat.at.i...k.co.jp/vmware/
Closing the image on the virtual disk 0...The image is closed.
Closing the image on the virtual disk 1...The drive is empty.
Closing the image on the virtual disk 2...The drive is empty.
Closing the image on the virtual disk 3...The drive is empty.
Stopped the Virtual Disk Driver.
Uninstalled the Virtual Disk Driver.
OS: Microsoft Windows XP Professional SP2 (ENU) + MUI French
#16
Posted 27 January 2008 - 05:45 PM
Quite obviously the problem must be in the parsing here:
FOR /F "tokens=2,3 delims=(/)" %A in ('ECHO ? | Format G: /FS:FAT /Q /V:NO_NAME | FIND ")? ?"') DO ( SET YES_Letter=%A SET NO_Letter=%B )
Please add a line like:
ECHO ? | Format G: /FS:FAT /Q /V:NO_NAMEor, better:
ECHO ? | Format %drive% /FS:FAT /Q /V:NO_NAMEin the batch just before the FOR statement and post output.
The feeding of a ? to FORMAT only works if the filesystem on the disk/image is RAW. i.e. it has not been formatted before, is it not that the problem occurred to you on a "second" run?
Also, if, for any reason, %filesystem% is not defined, the FOR won't work.
jaclaz
#17
Posted 01 February 2008 - 10:55 AM
Le type du systŠme de fichiers est RAW.
Le nouveau type de systŠme de fichiers est FAT.
Attentionÿ: toutes les donn‚es sur le lecteur de disque
non amovible G: seront perduesÿ!
Continuer le formatage (O/N)ÿ? ?
Attentionÿ: toutes les donn‚es sur le lecteur de disque
non amovible G: seront perduesÿ!
Continuer le formatage (O/N)ÿ?
Attentionÿ: toutes les donn‚es sur le lecteur de disque
non amovible G: seront perduesÿ!
Continuer le formatage (O/N)ÿ?
#18
Posted 01 February 2008 - 01:33 PM
The:
"Continuer le formatage " is definitely token 1
"O" is token 2
"N" is token 3
(given that delims are "(/)")
Consequently both variables YES_letter and NO_letter should be defined.
I cannot see why it does not work.
Can you post the rest of the output? Maybe it is the
FIND ")? ?"
part that does not work?
Try again with:
ECHO ? | Format %drive% /FS:FAT /Q /V:NO_NAME | FIND ")? ?"your output should be just:
Continuer le formatage (O/N)? ?
Otherwise, try with this:
ECHO ? | Format %drive% /FS:FAT /Q /V:NO_NAME | FIND ")"your output should be:
Continuer le formatage (O/N)? ?
Continuer le formatage (O/N)?
Continuer le formatage (O/N)?
jaclaz
#19
Posted 01 February 2008 - 01:39 PM
www.paraglidernc.com/files/getyes.zip
#20
Posted 01 February 2008 - 05:45 PM
1st/
D:\IDCS3>ECHO ? | Format G: /FS:FAT /Q /V:NO_NAME | FIND ")? ?"
D:\IDCS3>FOR /F "tokens=2,3 delims=(/)" %A in ('ECHO ? | Format G: /FS:FAT /Q /V:NO_NAME | FIND ")? ?"') DO (
SET YES_Letter=%A
SET NO_Letter=%B
)
D:\IDCS3>ECHO is first letter of the word that means "Yes" in your language
is first letter of the word that means "Yes" in your language
D:\IDCS3>ECHO is first letter of word that means "No" in your language
is first letter of word that means "No" in your language
2nd/
D:\IDCS3>ECHO ? | Format G: /FS:FAT /Q /V:NO_NAME | FIND ")"
Continuer le formatage (O/N)ÿ? ?
Continuer le formatage (O/N)ÿ?
Continuer le formatage (O/N)ÿ?
D:\IDCS3>FOR /F "tokens=2,3 delims=(/)" %A in ('ECHO ? | Format G: /FS:FAT /Q /V:NO_NAME | FIND ")? ?"') DO (
SET YES_Letter=%A
SET NO_Letter=%B
)
D:\IDCS3>ECHO is first letter of the word that means "Yes" in your language
is first letter of the word that means "Yes" in your language
D:\IDCS3>ECHO is first letter of word that means "No" in your language
is first letter of word that means "No" in your language
3rd/ working
D:\IDCS3>ECHO ? | Format G: /FS:FAT /Q /V:NO_NAME | FIND "? ?"
Continuer le formatage (O/N)ÿ? ?
D:\IDCS3>FOR /F "tokens=2,3 delims=(/)" %A in ('ECHO ? | Format G: /FS:FAT /Q /V:NO_NAME | FIND "? ?"') DO (
SET YES_Letter=%A
SET NO_Letter=%B
)
D:\IDCS3>(
SET YES_Letter=O
SET NO_Letter=N
)
D:\IDCS3>ECHO O is first letter of the word that means "Yes" in your language
O is first letter of the word that means "Yes" in your language
D:\IDCS3>ECHO N is first letter of word that means "No" in your language
N is first letter of word that means "No" in your language
4th/ original testpsc.cmd. I add blank space after ) and before ? in FIND ")? ?"
FOR /F "tokens=2,3 delims=(/)" %%A in ('ECHO ? ^| Format %Drive% /FS:%Filesystem% /Q /V:NO_NAME ^| FIND ")█? ?"') DO (
SET YES_Letter=%A
SET NO_Letter=%B
)
D:\IDCS3>ECHO O is first letter of the word that means "Yes" in your language
O is first letter of the word that means "Yes" in your language
D:\IDCS3>ECHO N is first letter of word that means "No" in your language
N is first letter of word that means "No" in your language
@Paraglider
Oui
with 1 as the parameter
O
Given that many punctuation "rules" are different in US English and French
The rules of punctuation are stricter in French than they are in English.English: no space before the colon.
Français█: un espace avant les deux-points.
English: no space before question mark?
Français : un espace avant le point d'interrogation█?
#21
Posted 01 February 2008 - 06:07 PM
Before running extra complicated scripts / tests etc:
Maybe you remember my 'chkdsk %systemdrive% /F' solution of post #6?
@bilou_gateux:
Can you try whether this also brings the troubles you mentioned above?
Peter
#22
Posted 01 February 2008 - 06:30 PM
@Jaclaz
Before running extra complicated scripts / tests etc:
Maybe you remember my 'chkdsk %systemdrive% /F' solution of post #6?
@bilou_gateux:
Can you try whether this also brings the troubles you mentioned above?
Peter
Your script output the correct answer yes.txt
but it creates 3 extras temp txt files.O
I like Jaclaz brainstormed scripting snippets.
#23
Posted 01 February 2008 - 06:34 PM
Anywhere I have a XP SP2 French CD ...Your script output the correct answer yes.txt
but it creates 3 extras temp txt files PSC: ??? I do not see a reason.
I like Jaclaz brainstormed scripting snippets.
I'm going to learn (WinBuilder) French ...
Peter
#24
Posted 01 February 2008 - 06:54 PM
On the other hand, because buildModel already writes a lot of shell32.dll's strings into projectinfo.ini, I just can extend the list by #17208 (thanks, paraglider!) and write the 'Y' or what is applicable, into projectinfo.ini
Maybe @PedroLe extends the API to 'GetYesChar,%Var%' >> Retrieve value YesChar from projectinfo.ini [OS]
EDIT: Sorry, Jaclaz! After reading your initial post again, I saw that this solution is not usable for you!
Peter
#25
Posted 02 February 2008 - 11:56 AM
Your script output the correct answer yes.txt
but it creates 3 extras temp txt files.
I like Jaclaz brainstormed scripting snippets.
Well, actually most of the credits in this case go to psc.
(@psc, please note how I did NOT bold your name )
...and if you think my batch snippets to be brainstormed, what are those by Yzöwl down at MSFN?
The idea of using
was to use just the first (out of three) outputs of the command, since the report of bilou_gateux about French punctuation we have TWO ways out as I see it:FIND ")? ?"
that will also assign the Yes and No letters from the first line, orFIND "? ?"
that will re-assign the letters three timesFIND ")"
Or, to remain without additional third part files, (BTW paraglider thanks a lot for your small proggie ) we may use FINDSTR instead of FIND, using widcards and regular expressions, something I've never come to study and and actually grasp.
About the temp files, you are talking of MKIMG now, don't you?
As said:
http://www.boot-land...?...=3191&st=13
Of course there are still a lot of small "corners to round" before a real release, like polishing up "remnants" and the like.
The number of downloads (19) of the "patched" 0.04 ALPHA version by Galapo till now and the amount of feedback received on it (yours only ) does not justify (yet) the "quantum leap" to version 0.5 (a "real" BETA), as I see it.
jaclaz
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users