Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Scripting file types

Reply
 
Old 08-19-2009   #1 (permalink)
Eric


 
 

Scripting file types

In the MS scripting documentation, they show how to put vbscript code into a
..wsf file (http://msdn.microsoft.com/en-us/libr...0h(VS.85).aspx).
The wsf file seems to be able to do stuff you can't do in a .vbs file. It
seems both file types are executed from wscipt/cscript. Is there any way to
do something like this ShowUsage method in a .vbs file? Is there anything
you can do with the .vbs file you can't do in a .wsh file? Should all
scripts then be written in .wsh files so you can add code like this (the
documentation for execution with the /? flag)? Is the .wsh just newer and
better than .vbs?



My System SpecsSystem Spec
Old 08-19-2009   #2 (permalink)
mr_unreliable


 
 

Re: Scripting file types

Eric wrote:
Quote:

> In the MS scripting documentation, they show how to put vbscript code into a
> .wsf file (http://msdn.microsoft.com/en-us/libr...0h(VS.85).aspx).
> The wsf file seems to be able to do stuff you can't do in a .vbs file. It
> seems both file types are executed from wscipt/cscript.
Yes.
Quote:

> Is there any way to do something like this ShowUsage method in a .vbs file?
Yes, but in a more crude way, such as showing an hta or msgbox.
Quote:

> Is there anything you can do with the .vbs file you can't do in a .wsh file?
No. The "wsh" file construct has more features than plain vbs.
Quote:

> Should all scripts then be written in .wsh files so you can add code like
> this (the documentation for execution with the /? flag)?
Not necessarily. If you need the wsh features, then use that.
If not, then you don't need to bother creating xml tags.
Quote:

> Is the .wsh just newer and better than .vbs?
Yes. But again, wsh is a bit more troublesome to write,
and so if you don't need those features, then why bother?

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
My System SpecsSystem Spec
Old 08-19-2009   #3 (permalink)
Eric


 
 

Re: Scripting file types

Thanks for the response.

If you're writing a quick and dirty script I might agree the .vbs file is
easier to write if the .wsf file requires all that extra text like "<job>",
but are you saying the .vbs is more troublesome to write if you're creating
a script library and you want well documented scripts?

The .wsf file has tags for an automatic help window with automatic text
formatting. If you call it with a /? it doesn't recognize as an argument.
It shows the help instead of trying to execute the script. If you want to
show the same window in a .vbs I assume you have to test
WScript.Arguments.Item(0) for "/?", then call the help message yourself and
exit.

What other features are available in .wsf which aren't available in .vbs?

What is a .wsh file? In my question I asked about a .wsf file with a link
to a page with a code sample that says save as .wsf. Then I got confused
since I'd been writing code all day using wsh objects and mentioned the file
type as .wsh further down, then you mentioned wsh in your response. If I
rename my .wsf file to .wsh, Windows still shows it with the scripting icon,
but if I click to run it I get an error.

"mr_unreliable" <kindlyReplyToNewsgroup@xxxxxx> wrote in message
news:uSdKxMPIKHA.4004@xxxxxx
Quote:

> Eric wrote:
Quote:

>> In the MS scripting documentation, they show how to put vbscript code
>> into a .wsf file
>> (http://msdn.microsoft.com/en-us/libr...0h(VS.85).aspx). The wsf
>> file seems to be able to do stuff you can't do in a .vbs file. It seems
>> both file types are executed from wscipt/cscript.
>
> Yes.
>
Quote:

>> Is there any way to do something like this ShowUsage method in a .vbs
>> file?
>
> Yes, but in a more crude way, such as showing an hta or msgbox.
>
Quote:

>> Is there anything you can do with the .vbs file you can't do in a .wsh
>> file?
>
> No. The "wsh" file construct has more features than plain vbs.
>
Quote:

>> Should all scripts then be written in .wsh files so you can add code like
>> this (the documentation for execution with the /? flag)?
>
> Not necessarily. If you need the wsh features, then use that.
> If not, then you don't need to bother creating xml tags.
>
Quote:

>> Is the .wsh just newer and better than .vbs?
>
> Yes. But again, wsh is a bit more troublesome to write,
> and so if you don't need those features, then why bother?
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
> the answers will be applicable to the questions)

My System SpecsSystem Spec
Old 08-19-2009   #4 (permalink)
Al Dunbar


 
 

Re: Scripting file types


"Eric" <someone@xxxxxx> wrote in message
news:u0XGCiPIKHA.4376@xxxxxx
Quote:

> Thanks for the response.
>
> If you're writing a quick and dirty script I might agree the .vbs file is
> easier to write if the .wsf file requires all that extra text like
> "<job>",
This is generally true, however, some script editors (i.e. primalscript)
manage all of the XML bits for you, making it almost as easy to create a q&d
script in .wsf format. With such an editor I'd consider using .wsf for even
the simplest scripts, as who has not seen a q&d script evolve into something
quite different?
Quote:

> but are you saying the .vbs is more troublesome to write if you're
> creating a script library and you want well documented scripts?
He might be. I would have said that myself, as the .WSF format allows script
code for functions, for example, to be shared between scripts without having
to cut&paste them.
Quote:

> The .wsf file has tags for an automatic help window with automatic text
> formatting. If you call it with a /? it doesn't recognize as an argument.
> It shows the help instead of trying to execute the script. If you want to
> show the same window in a .vbs I assume you have to test
> WScript.Arguments.Item(0) for "/?", then call the help message yourself
> and exit.
>
> What other features are available in .wsf which aren't available in .vbs?
See here:

http://msdn.microsoft.com/en-us/libr...7c(VS.85).aspx
http://www.herongyang.com/VBScript/W...ML-Format.html
Quote:

> What is a .wsh file? In my question I asked about a .wsf file with a link
> to a page with a code sample that says save as .wsf. Then I got confused
> since I'd been writing code all day using wsh objects and mentioned the
> file type as .wsh further down, then you mentioned wsh in your response.
> If I rename my .wsf file to .wsh, Windows still shows it with the
> scripting icon, but if I click to run it I get an error.
A .WSH file is used to hold a very limited amount of "property settings" for
a .VBS file. If you examine the properties of a .VBS file, you should see a
"script" tab. If you change anything in that tab, the result will be saved
in a .WSF file named for the .VBS file. Here is an example:

[ScriptFile]
Path=C:\Documents and Settings\Al\Desktop\testscript.vbs
[Options]
Timeout=3
DisplayLogo=1

If you double-click on the .WSH file, the corresponding .VBS file will be
run - with the two options as specified. This means that the .WSH file is
kind of a shortcut, which is why, on my system, at least, the scripting icon
is shown with a little arrow like a .LNK shortcut would be. Of course,
unlike a .LNK shortcut, the pointer to the .VBS file is not automatically
updated when the file is relocated.

IMHO, this is a throwback to the very early days of WSH, and not generally
of much use, as there is not very much that can be done with it.

/Al

Quote:

> "mr_unreliable" <kindlyReplyToNewsgroup@xxxxxx> wrote in message
> news:uSdKxMPIKHA.4004@xxxxxx
Quote:

>> Eric wrote:
Quote:

>>> In the MS scripting documentation, they show how to put vbscript code
>>> into a .wsf file
>>> (http://msdn.microsoft.com/en-us/libr...0h(VS.85).aspx). The wsf
>>> file seems to be able to do stuff you can't do in a .vbs file. It seems
>>> both file types are executed from wscipt/cscript.
>>
>> Yes.
>>
Quote:

>>> Is there any way to do something like this ShowUsage method in a .vbs
>>> file?
>>
>> Yes, but in a more crude way, such as showing an hta or msgbox.
>>
Quote:

>>> Is there anything you can do with the .vbs file you can't do in a .wsh
>>> file?
>>
>> No. The "wsh" file construct has more features than plain vbs.
>>
Quote:

>>> Should all scripts then be written in .wsh files so you can add code
>>> like this (the documentation for execution with the /? flag)?
>>
>> Not necessarily. If you need the wsh features, then use that.
>> If not, then you don't need to bother creating xml tags.
>>
Quote:

>>> Is the .wsh just newer and better than .vbs?
>>
>> Yes. But again, wsh is a bit more troublesome to write,
>> and so if you don't need those features, then why bother?
>>
>> cheers, jw
>> ____________________________________________________________
>>
>> You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
>> the answers will be applicable to the questions)
>
>


My System SpecsSystem Spec
Old 08-20-2009   #5 (permalink)
mayayana


 
 

Re: Scripting file types

Quote:

> The .wsf file has tags for an automatic help window with automatic text
> formatting. If you call it with a /? it doesn't recognize as an argument.
> It shows the help instead of trying to execute the script. If you want to
> show the same window in a .vbs I assume you have to test
> WScript.Arguments.Item(0) for "/?", then call the help message yourself
and
Quote:

> exit.
>
That's a handy feature in an EXE with no
documentation. It's somewhat traditional with
plain, utility-type EXEs to build in a/? option
so that the most basic docs for the EXE "travel
with it". But in the case of script files, I can't
see the point of writing the text for it in the
first place. A script is already plain text, for
goodness sake. One can just open it to read the
comments that one added to the script in the first
place.

I'm sure that some people really find that
sort of thing useful, but I think that a lot of
the features in WSH -- the help window you
mention, "script components", various XML
usages, script encoding -- are part of a sort of
inferiority complex on the part of scripters.

The *advantage* of script is that it's plain
text that doesn't need to be installed, registered,
etc. Yet those advantage are often removed by people
who think it's more fancy to dress up script so that
it looks more like "real EXEs".

Of course that's just my personal opinion, but
your post is mainly about personal preferences.
It's like discussing programming languages. There
are real strengths and weaknesses involved, but
the important thing is what works for you.


My System SpecsSystem Spec
Old 08-20-2009   #6 (permalink)
mr_unreliable


 
 

wsF vs wsH

Somewhere along the way, the O.P. switched from talking
about wsF files to talking about wsH files.

I missed it, you caught it.

my bad, jw
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
File Types-.jp2,jpc & jpe? General Discussion
associated file types Vista performance & maintenance
File types Vista General
File Types Vista General
File Types Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46