From: Daz on
Hi all,

i have been using a batch file to create my 7-zip sfx file, however i
am moving allot of my scripts from batch to vbs - can someone tell me
how i can do the following batch command in vbs please?

copy /b 7zip.sfx + comment-7zip.txt + "filename.7z" "newfilename.exe"

Cheers,
Daz
From: Pegasus (MVP) on

"Daz" <darren.blackley(a)gmail.com> wrote in message
news:b25aa596-e867-402b-bd48-1d9bbdafa016(a)u36g2000prf.googlegroups.com...
> Hi all,
>
> i have been using a batch file to create my 7-zip sfx file, however i
> am moving allot of my scripts from batch to vbs - can someone tell me
> how i can do the following batch command in vbs please?
>
> copy /b 7zip.sfx + comment-7zip.txt + "filename.7z" "newfilename.exe"
>
> Cheers,
> Daz

Here is what you do:
1. Open 7zip.sfx
2. Use the ReadAll method of the File System Object to
read the contents of this file into one long string.
3. Use the Write method to write the string into your
output file.
4. Do the same with the remaining files.
5. Close the output file.
If you don't have it already, download script56.chm to
find out the basic objects and methods for VB Scripting.

I'm not sure if it's such a good idea to translate your batch
files into VB Script. VB Scripting is much more powerful
than batch files but it also requires 6-10 times more code.
It is not unusual for a single batch file line to translate into
20 or 30 VB Script lines - and execution will be slower
too!


From: Daz on
On Jun 9, 11:28 pm, "Pegasus \(MVP\)" <I....(a)fly.com.oz> wrote:
> "Daz" <darren.black...(a)gmail.com> wrote in message
>
> news:b25aa596-e867-402b-bd48-1d9bbdafa016(a)u36g2000prf.googlegroups.com...
>
> > Hi all,
>
> > i have been using a batch file to create my 7-zip sfx file, however i
> > am moving allot of my scripts from batch to vbs - can someone tell me
> > how i can do the following batch command in vbs please?
>
> > copy /b 7zip.sfx + comment-7zip.txt + "filename.7z" "newfilename.exe"
>
> > Cheers,
> > Daz
>
> Here is what you do:
> 1. Open 7zip.sfx
> 2. Use the ReadAll method of the File System Object to
>     read the contents of this file into one long string.
> 3. Use the Write method to write the string into your
>     output file.
> 4. Do the same with the remaining files.
> 5. Close the output file.
> If you don't have it already, download script56.chm to
> find out the basic objects and methods for VB Scripting.
>
> I'm not sure if it's such a good idea to translate your batch
> files into VB Script. VB Scripting is much more powerful
> than batch files but it also requires 6-10 times more code.
> It is not unusual for a single batch file line to translate into
> 20 or 30 VB Script lines - and execution will be slower
> too!

Thanks for your input and advice. After sitting down and thinking
about it further as well as more searching on the net i came up with
the following work around :D

Act.run "%comspec% /c copy /b 7zip.sfx + comment-7zip.txt + " &
sArchiveName & ".7z " & sArchiveName & "." & bTime & ".exe", 0, True
From: ekkehard.horner on
Pegasus (MVP) schrieb:
> "Daz" <darren.blackley(a)gmail.com> wrote in message
> news:b25aa596-e867-402b-bd48-1d9bbdafa016(a)u36g2000prf.googlegroups.com...
>> Hi all,
>>
>> i have been using a batch file to create my 7-zip sfx file, however i
>> am moving allot of my scripts from batch to vbs - can someone tell me
>> how i can do the following batch command in vbs please?
>>
>> copy /b 7zip.sfx + comment-7zip.txt + "filename.7z" "newfilename.exe"
>>
>> Cheers,
>> Daz
>
> Here is what you do:
> 1. Open 7zip.sfx
> 2. Use the ReadAll method of the File System Object to
> read the contents of this file into one long string.

While this step is ok for text files, it will fail for binary
files. cf:

http://blogs.msdn.com/ericlippert/archive/2005/04/20/binary-files-and-the-file-system-object-do-not-mix.aspx


> 3. Use the Write method to write the string into your
> output file.
> 4. Do the same with the remaining files.
> 5. Close the output file.
> If you don't have it already, download script56.chm to
> find out the basic objects and methods for VB Scripting.
>
> I'm not sure if it's such a good idea to translate your batch
> files into VB Script. VB Scripting is much more powerful
> than batch files but it also requires 6-10 times more code.
> It is not unusual for a single batch file line to translate into
> 20 or 30 VB Script lines - and execution will be slower
> too!
>
>
From: Pegasus (MVP) on

"ekkehard.horner" <ekkehard.horner(a)arcor.de> wrote in message
news:484d51b0$0$27441$9b4e6d93(a)newsspool4.arcor-online.net...
> Pegasus (MVP) schrieb:
>> "Daz" <darren.blackley(a)gmail.com> wrote in message
>> news:b25aa596-e867-402b-bd48-1d9bbdafa016(a)u36g2000prf.googlegroups.com...
>>> Hi all,
>>>
>>> i have been using a batch file to create my 7-zip sfx file, however i
>>> am moving allot of my scripts from batch to vbs - can someone tell me
>>> how i can do the following batch command in vbs please?
>>>
>>> copy /b 7zip.sfx + comment-7zip.txt + "filename.7z" "newfilename.exe"
>>>
>>> Cheers,
>>> Daz
>>
>> Here is what you do:
>> 1. Open 7zip.sfx
>> 2. Use the ReadAll method of the File System Object to
>> read the contents of this file into one long string.
>
> While this step is ok for text files, it will fail for binary
> files. cf:
>
> http://blogs.msdn.com/ericlippert/archive/2005/04/20/binary-files-and-the-file-system-object-do-not-mix.aspx

I read what Eric Lippert said but I struggle to understand why this
code works happily with binary files:
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oOutputFile = oFSO.OpenTextFile("c:\output.bin", 2, True)
Copy "c:\Windows\system32\ntbackup.exe"
Copy "c:\Windows\system32\mmc.exe"
Copy "c:\Windows\system32\dxdiag.exe"
oOutputFile.Close

Sub Copy (sFileName)
Set oFile = oFSO.GetFile(sFilename)
Set oData = oFile.OpenAsTextStream
sString = oData.Read(oFile.Size)
oOutputFile.Write(sString)
oData.Close
End Sub