Prev: wait for external code to complete before continuing
Next: How do I configure Windows 2003 to get VBScript email with CDO
From: anime on 18 May 2010 10:18 "Tom Lavedas" <tglbatch(a)verizon.net> wrote in message news:bbbe77b3-cc21-46ad-a06b-e7755c230a58(a)c13g2000vbr.googlegroups.com... On May 17, 7:39 pm, "anime" <an...(a)nospam.microsoft.com> wrote: {snip} > > a bit more detailed code snippet here: > > Dim b > Function c(d) > c=chr(d) > End Function > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),..... > ..omitted..........c(000),c(000 ),"") > Set fso = CreateObject("Scripting.FileSystemObject") > Set f = fso.OpenTextFile("audio.wav", 2, True) > For i = 0 To 67593 > f.write(b(i)) > Next > f.close() > .... ....... > ..... > > This parts recovers encrypted audio file (67593 bytes size). How to modify > if use % char as separator (%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D) ? Let me see if I understand correctly. You have a string that contains 67,594 hex values in the %DD format that you want to write to a WAV file? Is that right? Actually, there is an intrinsic VBS function that translates that kind of a string directly - the unescape() function. In such a case, the solution might be as simple as ... s = "%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D" Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) f.write unescape(s) f.close() I say *might be* as this is attempting to create a binary file, which can cause the FSO write method some heartburn. Another way is to make use of the ADO binary stream to write the output instead, but I don't have a handy example of that. Plus, if done exactly as I show it, it should work to write binary data. _____________________ Tom Lavedas ----------- 67594 bytes is file size. I will be converted into hex format, then this script need recover it, i.e. to write to a binary WAV file. Can it be with specifying target file size? For i = 0 To 67593 Some converters gives a different hexadecimal string format representing, without separator ("717765727479206300000076626E.......000000"), or "\" separator. What in this case? ------- anime
From: Tom Lavedas on 18 May 2010 11:35 On May 18, 10:18 am, "anime" <an...(a)nospam.microsoft.news> wrote: > "Tom Lavedas" <tglba...(a)verizon.net> wrote in message > > news:bbbe77b3-cc21-46ad-a06b-e7755c230a58(a)c13g2000vbr.googlegroups.com... > On May 17, 7:39 pm, "anime" <an...(a)nospam.microsoft.com> wrote: > {snip} > > > > > > > a bit more detailed code snippet here: > > > Dim b > > Function c(d) > > c=chr(d) > > End Function > > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),..... > > ..omitted..........c(000),c(000 ),"") > > Set fso = CreateObject("Scripting.FileSystemObject") > > Set f = fso.OpenTextFile("audio.wav", 2, True) > > For i = 0 To 67593 > > f.write(b(i)) > > Next > > f.close() > > .... ....... > > ..... > > > This parts recovers encrypted audio file (67593 bytes size). How to modify > > if use % char as separator (%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D) ? > > Let me see if I understand correctly. You have a string that contains > 67,594 hex values in the %DD format that you want to write to a WAV > file? Is that right? > > Actually, there is an intrinsic VBS function that translates that kind > of a string directly - the unescape() function. In such a case, the > solution might be as simple as ... > > s = "%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D" > Set fso = CreateObject("Scripting.FileSystemObject") > Set f = fso.OpenTextFile("audio.wav", 2, True) > f.write unescape(s) > f.close() > > I say *might be* as this is attempting to create a binary file, which > can cause the FSO write method some heartburn. Another way is to make > use of the ADO binary stream to write the output instead, but I don't > have a handy example of that. Plus, if done exactly as I show it, it > should work to write binary data. > _____________________ > Tom Lavedas > > ----------- > > 67594 bytes is file size. I will be converted into hex format, then this > script need recover it, i.e. to write to a binary WAV file. > Can it be with specifying target file size? > For i = 0 To 67593 > > Some converters gives a different hexadecimal string format representing, > without separator ("717765727479206300000076626E.......000000"), or "\" > separator. What in this case? > ------- > anime If you keep changing the rules, there's no way to answer. You will need to figure it out yourself. I'll give it one more try and then you're on your own. s = "717765727479206376626E6D6D" for example s = "%71%77%65%72%74%79%20%63%76%62%6E%6D%6D" ' or this s = "\71\77\65\72\74\79\20\63\76\62\6E\6D\6D" ' or this Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) f.write decode(s) f.close() Function decode(s) Dim t1, t2, i d = Asc(Ucase(left(s, 1))) if d < Asc("0") OR d > Asc("F") then t1 = replace(s, Chr(d), "") else t1 = s end if for i = 1 to len(t1) step 2 t2 = t2 & chr("&H" & Mid(t1, i, 2)) next decode = t2 end function This should work for any length of string with any delimiter (or none). The delimiter cannot be any of the digits from 0 to 9 or A to F and each character must be defined by a two digit hex number. Other than that, it should work with any input string. _____________________ Tom Lavedas
From: anime on 19 May 2010 07:08 "Tom Lavedas" <tglbatch(a)verizon.net> wrote in message news:8732a41f-1e98-48d5-ba7c-e30bdd442759(a)d12g2000vbr.googlegroups.com... On May 18, 10:18 am, "anime" <an...(a)nospam.microsoft.news> wrote: > "Tom Lavedas" <tglba...(a)verizon.net> wrote in message > > news:bbbe77b3-cc21-46ad-a06b-e7755c230a58(a)c13g2000vbr.googlegroups.com... > On May 17, 7:39 pm, "anime" <an...(a)nospam.microsoft.com> wrote: > {snip} > > > > > > > a bit more detailed code snippet here: > > > Dim b > > Function c(d) > > c=chr(d) > > End Function > > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),..... > > ..omitted..........c(000),c(000 ),"") > > Set fso = CreateObject("Scripting.FileSystemObject") > > Set f = fso.OpenTextFile("audio.wav", 2, True) > > For i = 0 To 67593 > > f.write(b(i)) > > Next > > f.close() > > .... ....... > > ..... > > > This parts recovers encrypted audio file (67593 bytes size). How to > > modify > > if use % char as separator (%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D) > > ? > > Let me see if I understand correctly. You have a string that contains > 67,594 hex values in the %DD format that you want to write to a WAV > file? Is that right? > > Actually, there is an intrinsic VBS function that translates that kind > of a string directly - the unescape() function. In such a case, the > solution might be as simple as ... > > s = "%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D" > Set fso = CreateObject("Scripting.FileSystemObject") > Set f = fso.OpenTextFile("audio.wav", 2, True) > f.write unescape(s) > f.close() > > I say *might be* as this is attempting to create a binary file, which > can cause the FSO write method some heartburn. Another way is to make > use of the ADO binary stream to write the output instead, but I don't > have a handy example of that. Plus, if done exactly as I show it, it > should work to write binary data. > _____________________ > Tom Lavedas > > ----------- > > 67594 bytes is file size. I will be converted into hex format, then this > script need recover it, i.e. to write to a binary WAV file. > Can it be with specifying target file size? > For i = 0 To 67593 > > Some converters gives a different hexadecimal string format representing, > without separator ("717765727479206300000076626E.......000000"), or "\" > separator. What in this case? > ------- > anime If you keep changing the rules, there's no way to answer. You will need to figure it out yourself. I'll give it one more try and then you're on your own. s = "717765727479206376626E6D6D" for example s = "%71%77%65%72%74%79%20%63%76%62%6E%6D%6D" ' or this s = "\71\77\65\72\74\79\20\63\76\62\6E\6D\6D" ' or this Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) f.write decode(s) f.close() Function decode(s) Dim t1, t2, i d = Asc(Ucase(left(s, 1))) if d < Asc("0") OR d > Asc("F") then t1 = replace(s, Chr(d), "") else t1 = s end if for i = 1 to len(t1) step 2 t2 = t2 & chr("&H" & Mid(t1, i, 2)) next decode = t2 end function This should work for any length of string with any delimiter (or none). The delimiter cannot be any of the digits from 0 to 9 or A to F and each character must be defined by a two digit hex number. Other than that, it should work with any input string. _____________________ Tom Lavedas ---------------- Thank you for input. I want modify decoding a little just for HEX encoding with no delimiter. Function decode(s) Dim t1, t2, i d = Asc(Ucase(left(s, 1))) if d < Asc("0") OR d > Asc("F") then t1 = replace(s, Chr(d), "") else t1 = s end if for i = 1 to len(t1) step 2 t2 = t2 & chr("&H" & Mid(t1, i, 2)) next decode = t2 end function s = "717765727479206376626E....6D6D" Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) For i = 0 To 67593 f.write decode(s) f.close() Set WshShell = WScript.CreateObject("WScript.Shell") .... .... .... ..... Thanks.
From: Tom Lavedas on 19 May 2010 08:14 On May 19, 7:08 am, "anime" <an...(a)nospam.microsoft.news> wrote: > "Tom Lavedas" <tglba...(a)verizon.net> wrote in message > > news:8732a41f-1e98-48d5-ba7c-e30bdd442759(a)d12g2000vbr.googlegroups.com... > On May 18, 10:18 am, "anime" <an...(a)nospam.microsoft.news> wrote: > > > > > "Tom Lavedas" <tglba...(a)verizon.net> wrote in message > > >news:bbbe77b3-cc21-46ad-a06b-e7755c230a58(a)c13g2000vbr.googlegroups.com.... > > On May 17, 7:39 pm, "anime" <an...(a)nospam.microsoft.com> wrote: > > {snip} > > > > a bit more detailed code snippet here: > > > > Dim b > > > Function c(d) > > > c=chr(d) > > > End Function > > > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),..... > > > ..omitted..........c(000),c(000 ),"") > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > Set f = fso.OpenTextFile("audio.wav", 2, True) > > > For i = 0 To 67593 > > > f.write(b(i)) > > > Next > > > f.close() > > > .... ....... > > > ..... > > > > This parts recovers encrypted audio file (67593 bytes size). How to > > > modify > > > if use % char as separator (%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D) > > > ? > > > Let me see if I understand correctly. You have a string that contains > > 67,594 hex values in the %DD format that you want to write to a WAV > > file? Is that right? > > > Actually, there is an intrinsic VBS function that translates that kind > > of a string directly - the unescape() function. In such a case, the > > solution might be as simple as ... > > > s = "%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D" > > Set fso = CreateObject("Scripting.FileSystemObject") > > Set f = fso.OpenTextFile("audio.wav", 2, True) > > f.write unescape(s) > > f.close() > > > I say *might be* as this is attempting to create a binary file, which > > can cause the FSO write method some heartburn. Another way is to make > > use of the ADO binary stream to write the output instead, but I don't > > have a handy example of that. Plus, if done exactly as I show it, it > > should work to write binary data. > > _____________________ > > Tom Lavedas > > > ----------- > > > 67594 bytes is file size. I will be converted into hex format, then this > > script need recover it, i.e. to write to a binary WAV file. > > Can it be with specifying target file size? > > For i = 0 To 67593 > > > Some converters gives a different hexadecimal string format representing, > > without separator ("717765727479206300000076626E.......000000"), or "\" > > separator. What in this case? > > ------- > > anime > > If you keep changing the rules, there's no way to answer. You will > need to figure it out yourself. > > I'll give it one more try and then you're on your own. > > s = "717765727479206376626E6D6D" for example > s = "%71%77%65%72%74%79%20%63%76%62%6E%6D%6D" ' or this > s = "\71\77\65\72\74\79\20\63\76\62\6E\6D\6D" ' or this > Set fso = CreateObject("Scripting.FileSystemObject") > Set f = fso.OpenTextFile("audio.wav", 2, True) > f.write decode(s) > f.close() > > Function decode(s) > Dim t1, t2, i > d = Asc(Ucase(left(s, 1))) > if d < Asc("0") OR d > Asc("F") then > t1 = replace(s, Chr(d), "") > else > t1 = s > end if > for i = 1 to len(t1) step 2 > t2 = t2 & chr("&H" & Mid(t1, i, 2)) > next > decode = t2 > > end function > > This should work for any length of string with any delimiter (or > none). The delimiter cannot be any of the digits from 0 to 9 or A to > F and each character must be defined by a two digit hex number. Other > than that, it should work with any input string. > _____________________ > Tom Lavedas > ---------------- > > Thank you for input. I want modify decoding a little just for HEX encoding > with no delimiter. > > Function decode(s) > Dim t1, t2, i > d = Asc(Ucase(left(s, 1))) > if d < Asc("0") OR d > Asc("F") then > t1 = replace(s, Chr(d), "") > else > t1 = s > end if > for i = 1 to len(t1) step 2 > t2 = t2 & chr("&H" & Mid(t1, i, 2)) > next > decode = t2 > end function > > s = "717765727479206376626E....6D6D" > Set fso = CreateObject("Scripting.FileSystemObject") > Set f = fso.OpenTextFile("audio.wav", 2, True) > For i = 0 To 67593 > f.write decode(s) > f.close() > Set WshShell = WScript.CreateObject("WScript.Shell") > ... .... > ... ..... > > Thanks. Function decode(s) Dim t, i for i = 1 to len(s) step 2 t = t & chr("&H" & Mid(s, i, 2)) next decode = t end function s = "717765727479206376626E....6D6D" Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) f.write decode(s) f.close() I suggest you get the downloadable WSH documentation and start using it. Also, the Script Center Example library. WSH 5.6 documentation download (URL all one line) http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en TechNet Script Center Sample Scripts (URL all one line) http://www.microsoft.com/downloads/details.aspx?FamilyID=b4cb2678-dafb-4e30-b2da-b8814fe2da5a _____________________ Tom Lavedas
From: anime on 19 May 2010 09:06
"Tom Lavedas" <tglbatch(a)verizon.net> wrote in message news:c216e015-bbce-4271-a548-08524b569748(a)f14g2000vbn.googlegroups.com... On May 19, 7:08 am, "anime" <an...(a)nospam.microsoft.news> wrote: > "Tom Lavedas" <tglba...(a)verizon.net> wrote in message > > news:8732a41f-1e98-48d5-ba7c-e30bdd442759(a)d12g2000vbr.googlegroups.com... > On May 18, 10:18 am, "anime" <an...(a)nospam.microsoft.news> wrote: > > > > > "Tom Lavedas" <tglba...(a)verizon.net> wrote in message > > >news:bbbe77b3-cc21-46ad-a06b-e7755c230a58(a)c13g2000vbr.googlegroups.com... > > On May 17, 7:39 pm, "anime" <an...(a)nospam.microsoft.com> wrote: > > {snip} > > > > a bit more detailed code snippet here: > > > > Dim b > > > Function c(d) > > > c=chr(d) > > > End Function > > > b=Array(c(204),c(224),c(128),c(056),c(093),c(131),c(232),c(098),c(033),..... > > > ..omitted..........c(000),c(000 ),"") > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > Set f = fso.OpenTextFile("audio.wav", 2, True) > > > For i = 0 To 67593 > > > f.write(b(i)) > > > Next > > > f.close() > > > .... ....... > > > ..... > > > > This parts recovers encrypted audio file (67593 bytes size). How to > > > modify > > > if use % char as separator (%71%77%65%72%74%79%20%63%76%62%6E% > > > ...6D%6D) > > > ? > > > Let me see if I understand correctly. You have a string that contains > > 67,594 hex values in the %DD format that you want to write to a WAV > > file? Is that right? > > > Actually, there is an intrinsic VBS function that translates that kind > > of a string directly - the unescape() function. In such a case, the > > solution might be as simple as ... > > > s = "%71%77%65%72%74%79%20%63%76%62%6E% ...6D%6D" > > Set fso = CreateObject("Scripting.FileSystemObject") > > Set f = fso.OpenTextFile("audio.wav", 2, True) > > f.write unescape(s) > > f.close() > > > I say *might be* as this is attempting to create a binary file, which > > can cause the FSO write method some heartburn. Another way is to make > > use of the ADO binary stream to write the output instead, but I don't > > have a handy example of that. Plus, if done exactly as I show it, it > > should work to write binary data. > > _____________________ > > Tom Lavedas > > > ----------- > > > 67594 bytes is file size. I will be converted into hex format, then this > > script need recover it, i.e. to write to a binary WAV file. > > Can it be with specifying target file size? > > For i = 0 To 67593 > > > Some converters gives a different hexadecimal string format > > representing, > > without separator ("717765727479206300000076626E.......000000"), or "\" > > separator. What in this case? > > ------- > > anime > > If you keep changing the rules, there's no way to answer. You will > need to figure it out yourself. > > I'll give it one more try and then you're on your own. > > s = "717765727479206376626E6D6D" for example > s = "%71%77%65%72%74%79%20%63%76%62%6E%6D%6D" ' or this > s = "\71\77\65\72\74\79\20\63\76\62\6E\6D\6D" ' or this > Set fso = CreateObject("Scripting.FileSystemObject") > Set f = fso.OpenTextFile("audio.wav", 2, True) > f.write decode(s) > f.close() > > Function decode(s) > Dim t1, t2, i > d = Asc(Ucase(left(s, 1))) > if d < Asc("0") OR d > Asc("F") then > t1 = replace(s, Chr(d), "") > else > t1 = s > end if > for i = 1 to len(t1) step 2 > t2 = t2 & chr("&H" & Mid(t1, i, 2)) > next > decode = t2 > > end function > > This should work for any length of string with any delimiter (or > none). The delimiter cannot be any of the digits from 0 to 9 or A to > F and each character must be defined by a two digit hex number. Other > than that, it should work with any input string. > _____________________ > Tom Lavedas > ---------------- > > Thank you for input. I want modify decoding a little just for HEX encoding > with no delimiter. > > Function decode(s) > Dim t1, t2, i > d = Asc(Ucase(left(s, 1))) > if d < Asc("0") OR d > Asc("F") then > t1 = replace(s, Chr(d), "") > else > t1 = s > end if > for i = 1 to len(t1) step 2 > t2 = t2 & chr("&H" & Mid(t1, i, 2)) > next > decode = t2 > end function > > s = "717765727479206376626E....6D6D" > Set fso = CreateObject("Scripting.FileSystemObject") > Set f = fso.OpenTextFile("audio.wav", 2, True) > For i = 0 To 67593 > f.write decode(s) > f.close() > Set WshShell = WScript.CreateObject("WScript.Shell") > ... .... > ... ..... > > Thanks. Function decode(s) Dim t, i for i = 1 to len(s) step 2 t = t & chr("&H" & Mid(s, i, 2)) next decode = t end function s = "717765727479206376626E....6D6D" Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("audio.wav", 2, True) f.write decode(s) f.close() I suggest you get the downloadable WSH documentation and start using it. Also, the Script Center Example library. WSH 5.6 documentation download (URL all one line) http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en TechNet Script Center Sample Scripts (URL all one line) http://www.microsoft.com/downloads/details.aspx?FamilyID=b4cb2678-dafb-4e30-b2da-b8814fe2da5a _____________________ Tom Lavedas ------------------ Thank you for the help, Tom. Looks, Vbscript not supported anymore on Vista and Windows 7? anime |