VB Scripting - New and need help!

Hi all,
I have a quick question for you guy, but need an answer to quickly.  I am wondering what I will need to start making some VBSCRIPTS.  What program will I need?  Also, what program(s) do the client computers that are running these scripts require?

My goal is to run these VB scripts on client machines so I don't have to manually configure specific settings.  I've done most in batch, but want to move over to VB.  I don't know the first thing about VB, but will try to learn some as I go along.

Please help me if you can.

Thanks,
JSCTECHY
LVL 1
jsctechyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rettiseertCommented:
If your computer has Internet Explorer 5 or above you already have all you need to run VBS.

As a bat file, you just need to edit a text file with your code but use the extension VBS, the double click the icon and the code will run
0
rettiseertCommented:
0
jsctechyAuthor Commented:
thanks for the replies.
I see some stuff about Cscript, WSH also.
Using VB Scripting, can you call WSH?  Or am I totally lost?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

sirbountyCommented:
JSCTECHY, most Microsoft clients will run vbscripting/wsh scripts (basically these are the same).
You create a script using a text editor - notepad, for example.

Wscript.echo "Hello"

is all you need to write your first script.
Of course, you can get fancy with it, as you learn.
The clients will be able to run it - but here's the difference:
There are 2 methods for calling a vbscript:
1) Cscript.exe - this is useful when you want the above .echo to simply write some text on screen - not generate a popup.  There's not a lot of difference between the two methods outside of this.
1) Wscript.exe - this is the default method and if cscript is not explicitly used, this will be.  It's, obviously, the method used if you double-click on a script as well.

The only other thing required is to name the script.  .VBS is usually the extension, but you can use .VBE, among others...
0
jsctechyAuthor Commented:
Sirbounty,
I understand what you mean.  But when you write batch, you can always do a /?, is there something you can use to do that w/ VB Scripting, or do I just reference a help site?
0
sirbountyCommented:
google is your friend there.

Fortunately, you'll get 'some' indication when you attempt to code and it's not quite right...it'll tell you at least what line # the error is on.

You can get better quality errors by using

On Error Resume Next
at the head of your code and then

wscript.echo err.Description
after whereever you expect an error - for whatever reason.

But no, there's no context help for the commands....

Activeexperts.com and the scripting guy at Microsoft are two of my favorite sites for help!
0
jsctechyAuthor Commented:
Thanks for the info-
One last thing..  In the code below, what is it saying? I know it will run 'notepad.exe', but why all the additional text?

dim wshshell
set wshShell = Wscript.CreateObject("Wscript.Shell")
wshshell.Run "notepad.exe"
0
sirbountyCommented:
Well - the first line is just for clarity (and better coding practive):
You're 'declaring' that somewhere in the following code, you will be using that variable.
The second line is the one that uses it - and assigns it to an object reference to the wscript shell method.
The last simply uses that object reference to run an external file...
0
jsctechyAuthor Commented:
I see.  So I can do something like this:

On Error Resume Next
dim Runprog
set RunProg = wscript.CreateObject("wscript.Shell")
Runprog.Run "\\Jsfs1\APPS\OFFICE2003\OFFICE\setup.exe PIDKEY=XXXXXXXXXXXXXXXXXXXXXXXXX
USERNAME=Setup COMPANYNAME="Name." /qb"

When in batch I was doing this:

\\Jsfs1\APPS\OFFICE2003\OFFICE\setup.exe PIDKEY=XXXXXXXXXXXXXXXXXXXXXXXXX USERNAME=Setup COMPANYNAME="Name" /qb

It seems like there is way more text when using the VB.  But as you get more advanced later on, Batch just doesn't cut it, correct?
0
sirbountyCommented:
Well - I'm not going to be snared into that one...cause I know of a few DOS batch experts that would be quick to jump on me!! :^)

But, sometimes it's just the oppoosite..it really depends - I still use batch scripts for 'small' stuff...and if 'all' you're doing is using the shell for running a program, I don't see a need to use vbs anyway...

But for the above - the problem you'll run into is your use of the quotes:
When they're needed by the 'shelled' app, you'll need to put them in there, else it'll fudge the whole Run line...see here:  Chr(34) is one way for doing this:

Runprog.Run chr(34) & "\\Jsfs1\APPS\OFFICE2003\OFFICE\setup.exe PIDKEY=XXXXXXXXXXXXXXXXXXXXXXXXX
USERNAME=Setup COMPANYNAME=" & chr(34) & "Name." & chr(34) & " /qb"

You can also double-up on the quotes to accomplish the same thing...
0
jsctechyAuthor Commented:
Sir,
I am just running programs for now until I can get used to how things work.  I'll eventually want to create IP ports and add printers based on AD groups.  Also would like to automate some tasks.
0
sirbountyCommented:
Then I'd suggest you grab the download the HSG archive...http://www.microsoft.com/technet/scriptcenter/resources/qanda/hsgarch.mspx
Great info on AD queries! :^)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jsctechyAuthor Commented:
cool, thanks a lot.  I'll look into all this information.
0
sirbountyCommented:
Happy to help - thanx for the grade! :^)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.