Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB Scripting - New and need help!

Posted on 2007-03-29
14
Medium Priority
?
157 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:jsctechy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 2
14 Comments
 
LVL 13

Expert Comment

by:rettiseert
ID: 18818174
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
 
LVL 13

Expert Comment

by:rettiseert
ID: 18818187
0
 
LVL 1

Author Comment

by:jsctechy
ID: 18818344
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 67

Expert Comment

by:sirbounty
ID: 18818503
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
 
LVL 1

Author Comment

by:jsctechy
ID: 18818578
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18818606
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
 
LVL 1

Author Comment

by:jsctechy
ID: 18818663
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18818801
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
 
LVL 1

Author Comment

by:jsctechy
ID: 18818911
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18819015
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
 
LVL 1

Author Comment

by:jsctechy
ID: 18819185
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
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 18819208
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
 
LVL 1

Author Comment

by:jsctechy
ID: 18819285
cool, thanks a lot.  I'll look into all this information.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18819325
Happy to help - thanx for the grade! :^)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question