![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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. Quote: > Is there any way to do something like this ShowUsage method in a .vbs file? Quote: > Is there anything you can do with the .vbs file you can't do in a .wsh file? Quote: > Should all scripts then be written in .wsh files so you can add code like > this (the documentation for execution with the /? flag)? If not, then you don't need to bother creating xml tags. Quote: > Is the .wsh just newer and better than .vbs? 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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>", 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? 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? 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 .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 Specs![]() |
| | #5 (permalink) |
| | 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 Quote: > exit. > 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||