Discussion:
Beginners question
(too old to reply)
c***@gmail.com
2014-03-29 00:24:44 UTC
Permalink
Hello, I'm new to vb script and hoping someone can point me in a direction...

See the following parts from 2 scripts:

Set Our_Printers = CreateObject("WScript.Network")
Our_Printers.AddWindowsPrinterConnection Printer_1

set fso = CreateObject("Scripting.FileSystemObject")
if fso.FolderExists("c:\windows") then
WScript.echo "There is a folder named \Windows"

My first question is, is there a list of available objects that can be used after CreateObject? Additionally, is there a list of properties (i believe that's what they are called), that can be used? For example, what else can I use along with AddWindowsPrinterConnection?

Thank you.
Mayayana
2014-03-29 03:05:27 UTC
Permalink
My first question is, is there a list of available objects that can be used
after CreateObject? Additionally, is there a list of properties (i believe
that's what they are called), that can be used? For example, what else can
I use along with AddWindowsPrinterConnection?
There are multiple answers to that question. You probably
want to get the help file, here:

http://www.microsoft.com/en-us/download/details.aspx?id=2764

You'll see in the help that there are several objects,
like Scripting.FileSystemObject, WScript.Shell and
Shell.Application. But those are just the objects officially
assigned to be part of VBScript in Windows Script Host
usage.

There's also VBScript for IE automation, MS Word
automation, etc.

There can also be an unlimited number of other objects.
An object must be registered on the system to be created.
It must offer a Dispatch or late-binding interface, and in
most cases it must offer methods, properties and events
that use variant data types. (That sentence may not make
much sense, but you can research it.)

You can find methods/properties/events of objects in
a number of ways. One way is through sample code. One
way is through documentation. And one way is by using
an object browser, which is software that can read the
documentation embedded in a type library, which is often
embedded in the creatable object executable file. (Another
thing you'll need to research.)

I have a lot of information, samples and components
(providing custom objects) here:

http://www.jsware.net/jsware/scripts.php5

There are also other sources of scripts and information.
VBScript is being de-emphasized by Microsoft at this point.
It doesn't even work in IE 11 under some circumstances.
But in general it's still usable in all versions of Windows.
c***@gmail.com
2014-03-29 13:51:49 UTC
Permalink
Thanks for that! A lot to review!

One follow up: if Microsoft is moving away from VB script, what is the new recommended language to use for login scripts, adding printers, getting AD info etc?

Thank you.
Mayayana
2014-03-29 15:31:11 UTC
Permalink
| One follow up: if Microsoft is moving away from VB script, what is the
new recommended language to use for login scripts, adding printers, getting
AD info etc?
|

That's another complex question. MS originally created VBS
to compete with Netscape in the browser. Then they adapted
it to the Windows Script Host, which was intended to be like
DOS BAT files updated for GUI scripting. That worked out pretty
well, and VBS is still used widely. It's used widely by corporate
IT people and is even a standard option for custom operations
in MSI installers.

Since the early days several things have happened:

1) MS is desperately trying to get IE accepted as a standards
compliant browser, and VBScript is not part of any browser
functionality except IE. In what seems to be a move of deference,
MS has made VBS not work in IE 11 in what they call "edge
mode", which is their term for HTML5. In practice that's really
a meaningless gesture. No one would try to use VBS in HTML5.
It only ever worked in IE, anyway, and IE now has a very small
market share.

2) Over the years, MS has been trying to increase Windows
security, partly for good reason and partly because they want
to gradually lock down the system in order to sell services,
with Windows being sort of kiosk-only mode. In accord with
that move they're not encouraging people to do home-baked
programming.

3) MS came out with PowerShell, which was designed to be
a DOS replacement that operates more like the various Linux
shells. The idea is to lure Linux admins away from Linux
servers and sell them on Windows server.

What all of that means is that VBS is still supported, Windows
Script Host is still part of Windows, and IE still supports VBS for
any real-world use you might want. But MS has several motives
to treat VBS like a poor cousin.

If you like console operations you might want to look into
PowerShell. MS recommends it. But they only recommend it
for the reasons listed above. You don't have to worry about
VBS going away for the uses you want. In any situation where
you can't use VBS in the future it's likely that you won't
be able to use anything else comparable, either.
Dave "Crash" Dummy
2014-03-29 15:06:10 UTC
Permalink
Mayayana wrote:

<snipped>
There are also other sources of scripts and information. VBScript is
being de-emphasized by Microsoft at this point. It doesn't even work
in IE 11 under some circumstances. But in general it's still usable
in all versions of Windows.
I hope they don't abandon VBScript completely. I have a lot of time
invested in learning the language and writing VBS and HTA programs. I
don't much care about client side scripts for IE, but I hope the
InternetExplorer application will still be around.
--
Crash

"When you get to a fork in the road, take it."
~ Yogi Berra ~
Mayayana
2014-03-29 20:48:51 UTC
Permalink
| I hope they don't abandon VBScript completely.

That would be pretty unlikely as long as there are
corporate customers still using scripts. That's the
nice thing about MS: They cater to corporate
customers, who need to maintain backward
compatibility. Even the limiting of support for VBS in
IE 11 is just a token gesture. As long as you
don't use HTML5 DOCTYPE it should work fine.
I never use any DOCTYPE for pages going to IE,
or for HTAs, because that gives me "quirks mode"
display, so I can depend on everyone seeing
the same page, regardless of IE version.

I did run into an unrelated issue recently, though.
Microsoft has changed the IE 11 userAgent:

"Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"

For years I, and many others, have identified IE by the string
"MSIE". Microsoft is deliberately trying to get Firefox pages
in IE 11. I have my site giving out 2 versions of my webpages.
One uses VBScript to operate dropdown menus, in quirks mode,
and works in all versions of IE. The other version goes to all
other browsers and uses CSS, with no script. I could just let IE
11 have the non-IE version, but IE in the past has been unpredictable
about layout. I know my IE pages in quirks mode look right. I don't
know if they look right in IE11. And I'm not going to buy a Win8 PC
just to try that out. So my site now checks for "Trident" as well as
"MSIE" and gives the IE pages to all of those. Since it's quirks mode
the VBS should work, but frankly I don't much care at this point.
IE has become a niche browser.

| I have a lot of time
| invested in learning the language and writing VBS and HTA programs. I
| don't much care about client side scripts for IE, but I hope the
| InternetExplorer application will still be around.
Wally W.
2014-03-29 22:00:31 UTC
Permalink
Post by Mayayana
| I hope they don't abandon VBScript completely.
That would be pretty unlikely as long as there are
corporate customers still using scripts. That's the
nice thing about MS: They cater to corporate
customers,
Irony. MS prospered at the expense of IBM for doing what MS now does:
cater to the corporate customers (IT departments, not end-users).

MS freed us from the big box in another room. Now, the IT departments
monitor every keystroke on "personal" computers with no admin rights
that would allow people to install software that helps them get their
work done.
Post by Mayayana
who need to maintain backward
compatibility. Even the limiting of support for VBS in
IE 11 is just a token gesture. As long as you
don't use HTML5 DOCTYPE it should work fine.
I never use any DOCTYPE for pages going to IE,
or for HTAs, because that gives me "quirks mode"
display, so I can depend on everyone seeing
the same page, regardless of IE version.
I did run into an unrelated issue recently, though.
"Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"
For years I, and many others, have identified IE by the string
"MSIE". Microsoft is deliberately trying to get Firefox pages
in IE 11. I have my site giving out 2 versions of my webpages.
One uses VBScript to operate dropdown menus, in quirks mode,
and works in all versions of IE. The other version goes to all
other browsers and uses CSS, with no script. I could just let IE
11 have the non-IE version, but IE in the past has been unpredictable
about layout. I know my IE pages in quirks mode look right. I don't
know if they look right in IE11. And I'm not going to buy a Win8 PC
just to try that out. So my site now checks for "Trident" as well as
"MSIE" and gives the IE pages to all of those. Since it's quirks mode
the VBS should work, but frankly I don't much care at this point.
IE has become a niche browser.
| I have a lot of time
| invested in learning the language and writing VBS and HTA programs. I
| don't much care about client side scripts for IE, but I hope the
| InternetExplorer application will still be around.
c***@gmail.com
2014-03-29 23:25:26 UTC
Permalink
Thanks a lot! Some good info to know.

Thanks for your time.
Evertjan.
2014-03-30 08:00:05 UTC
Permalink
Post by c***@gmail.com
Thanks a lot! Some good info to know.
Thanks for your time.
This is usenet, not email.

We have no idea what you are respondong on,
and to whom,
if you do not quote relevant text.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mayayana
2014-03-30 13:49:41 UTC
Permalink
| Thanks a lot! Some good info to know.
|
| Thanks for your time.

Your questions potentially help others, and
they keep this group going. (A lot of people
don't know the Microsoft newsgroups are still
running, so usage has dropped off.)

And don't be bothered by Evertjian. As you may
know, there are some people on Usenet who still
live in the 90s and think that upholding outdated
rules is more important than practicing basic
courtesy.
He will not compromise and he will not be placated.
There's no sense trying.

Loading...