Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the purpose of the VBScript?

Status
Not open for further replies.

kruxty

Programmer
Jul 17, 2001
197
PT
Is VBscripting only for web pages or can i use it with windows and make some aplications (scripts) for it?
If this is possible, can you give me some examples?
 
vbscript is best suited to small scripts to do admin type tasks. it is also suited to logonscripts. it has basic gui functionality stand alone. it cant call API's directly, well not without some messing around.
i have vbscripts which are 2000 odd lines long. we use scripts to handle automatic w2k to wxp upgrades on pcs without user intervention. this includes all pre software upgrades, the os upgrade and then post installation software installs and upgrades.
we have a script which handles unattended w2k and wxp installations.
our logon script is based on 4 levels of ini files. enterprise, location, group, user. the logon script is component based and each component is configurable based on LAN/RAS/VPN/WAN. based on connection type you can turn components on or off in each of the ini files, one can also configure the logging options from file, screen, file&screen, eventlogonly, full, file&eventlog.

i guess all i am trying to say is that vbscript is capable of just about anything your imagination and determination allows.

have fun.
start with WSH then moved onto ADSI and WMI would be my advice if you want to look into vbscripts capabilites with regards to windows, AD, computer config and management, automatic builds etc
 
:D Tks

I've some concepts of Visual Basic, and i'm starting (right now) to read the manual of vbscripting!
I don't understand one thing... What are the extension of the files that run the scripts?
And how DOS know that the code is VBS instead of DOS code?
 
you can have vbscript code contained in a number of different file extensions. there are possibly too many to mention.
to start off with i would concern your self with .vbs files.

you can run your script by double clickikng on the vbs file and this will run your default engine,,probably wscript.exe.

cscript.exe is sometimes better. you would want to go to a command prompt and type "cscript.exe d:\test.vbs"
this would mean your wscript.echo's would be displayed in the dos box and you wouldnt have to worry about clicking on the ok button of msgboxs, that way it might be easier to debug. also it would make it eassy to pipe outputs of your scripts to text files until you learn abour textstreams and textfiles...ie
cscript.exe d:\test.vbs > d:\testresults.txt
 
Sub GuessANumber
Dim Guess, RndNum
RndNum = Int((100) * Rnd(1) + 1)
Guess = CInt(InputBox("Enter your guess:",,0))
Do
If Eval("Guess = RndNum") Then
MsgBox "Congratulations! You guessed it!"
Exit Sub
Else
Guess = CInt(InputBox("Sorry! Try again.",,0))
End If
Loop Until Guess = 0
End Sub





---------------------------------------
I've this code (It's present in Microsoft documentation) and put it in c:\test.vbs .
But i double click it and nothing happen? Why?
Sorry if i'm being a pain in your neck...
 
Add a Call to the sub in front of your script

Hope This Help
PH.
 
Not really...

Can you explain that better!?
 
the script execution will start at the top of your vbscript file.
you have declared a sub routine. something has to start this sub routine.
if you remove the Sub GuessANumber and End sub then when the script is run it will carry out your commands. either that or right at the top of your script have

Call GuessANumber()
 
Need some more help...

What is the function that gives me all the files on a directory?
I want to make some code to compare name files!
 
have a look at the thread
"using Files collection with ASP" ignore the asp stuff

or go to msdn online and take a look at the files collection object

Set objFld = FSO.GetFolder("c:\temp")
For Each aFile In objFld.Files
Wscript.Echo aFile.Name & vbTab & aFile.Size
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top