• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 501
  • Last Modified:

VBS Scripts (Windows Script Host)

Hi experts!

I know that we can do a lot of things with vbs files (Windows script host) in windows environment. Controlling every thing!
But I'm not familiar with VB language so I can't write one of them myself and have always copy pasted them from net!
I searched a lot but couldn't find a good and complete guide to write VBS scripts. There are some sites but not as good as I want!

1) Please introduce a good reference or list of commands (if any!)
Sites or E-books

2) If you have any useful vbs script that helps doing jobs easier in windows, I love to see it!
Post any good vbs scripts you have! I appreciate every script.

Examples: scripts for log on, log off, controlling windows GUI of windows, changing network settings, showing messages and prompts, timers, etc . . .

Thanks in advance
0
Arman Khodabande
Asked:
Arman Khodabande
5 Solutions
 
DSmithVzCommented:
To answer your first question. W3Schools.com has a good tutorial you can step through to learn VBScript and has reference to the built in functions.
Tutorial:
http://www.w3schools.com/vbscript/default.asp
Function Reference:
http://www.w3schools.com/vbscript/vbscript_ref_functions.asp
0
 
Arman KhodabandeAuthor Commented:
I've seen that site before  . . .
It's about HTML scripting and doesn't contain commands used in "WSH".
I need commands which can be processed by Windows script host.
Go to above page in wiki to understand what is required about vbscript.

Thanks
0
 
Arman KhodabandeAuthor Commented:
I found good examples here. But need more . . .
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
CharlWiehahnCommented:
Hi kpax77,

I taught myself WSH by copying scripts off the net and using the help file provided my microsoft to read up on functions I did not understand. Here is the link to download the 2mb help file.

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=2764
0
 
QlemoC++ DeveloperCommented:
I agree to the said above. Best is indeed to use the individual sources for your issue on the Web. If you really want to get into it, you can use a Visual Basic beginners book - adopting to VBScript isn't difficult then, though it is more restricted (e.g. does not allow strict var types).
Just posting VBScripts here unspecifically doesn't make sense, as you will find tons of them when searching.
Another good way to learn something about a particular, useful VBScript you found is to post a question here about that script. Experts will be happy to explain how it works then, and expand it together with you if needed.
0
 
cantorisCommented:
The original Windows 2000 Scripting Guide introduces VB, WSH, WMI, ADSI and the Scripting Runtime.
http://technet.microsoft.com/en-gb/library/ee692931.aspx
It's long but I strongly recommend you read it if you want to learn any of this stuff.  I bought the weighty tome and read it cover to cover - an excellent book.

I recommend you install the Windows SDK v7.0 (avoid 7.1 with its appalling help system):
http://www.microsoft.com/download/en/details.aspx?id=18950
It's documentation will be your scripting bible - though it can be difficult to find things.  The important bits are hiding in the following nodes of the documentation:

Web Development - Microsoft Windows Script Technologies: here are VBScript, WSH and "Script Runtime" - the latter includes the FileSystemObject and Dictionary object which you will use a lot.
Win32 and COM Development - Administration and Management - Windows Management Instrumentation - WMI Reference: You'll find the various WMI Win32_ classes here.  Very useful for remote management.  You'll also find the WMI Registry Classes node here which contains the info for the extremely useful StdRegProvider.
Web Development - HTML and CSS - HTML Applications - Reference: This is the info on HTA files if you want to make those too.

Give yourself a good grounding of the basics with that free scripting book and then you'll be in a position to work out what other people's scripts do.  When you find a problem you think would make good use of a scripted solution, look it up online and find someone else's solution.  Then read through the script to try and understand what it is doing - use the SDK reference material to help you.
0
 
Arman KhodabandeAuthor Commented:
Thank you for your invaluable advice.
I'll have a look at them.
will come back soon . . .

Best regards
Kpax7
0
 
cantorisCommented:
Well you wanted scripts too, so here's one.
It started off as one of my earliest bits of VBScript and WMI but has since grown and been chopped up into subroutines to make it easier to debug, add to and be more logically satisfying.  It's something that runs as part of a runonce.bat file on all our freshly imaged XP PCs (both Dell and HP).  It's called via CScript.exe so it can echo out info to the command prompt, as that also displays status messages from the parent batch file.

Its purpose is to set the hostname of the local PC to something unique and it does this by checking various WMI classes that I have found on our different models of PC to contain something suitable.  Over time I've added in extra classes as I've found new PCs models that have nothing suitable in the existing ones I was checking.  That's when I ended up breaking it up into subroutines to make the code cleaner.

Enjoy!
ChangeName.vbs
0
 
Arman KhodabandeAuthor Commented:
Thanks all.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now