Discussion:
Include a vbs file into another vbs file
(too old to reply)
Jake
2008-01-25 11:37:27 UTC
Permalink
Hi,

I have som common procedures in my logon files and I want to gather all
these in a file general-logon.vbs

Then I want to make user group specific logon files which all starts by
including this general-logon.vbs file at the top.

What is the syntax for including a vbs file in this scenario?

Jake
Pegasus (MVP)
2008-01-25 11:48:43 UTC
Permalink
Post by Jake
Hi,
I have som common procedures in my logon files and I want to gather all
these in a file general-logon.vbs
Then I want to make user group specific logon files which all starts by
including this general-logon.vbs file at the top.
What is the syntax for including a vbs file in this scenario?
Jake
This link might help:
http://www.naterice.com/blog/template_permalink.asp?id=53
mayayana
2008-01-25 13:11:50 UTC
Permalink
Sub IncludeFile(sPath)
Dim FSO1, s1, TS1
Set FSO1 = CreateObject("Scripting.FileSystemObject")
Set TS1 = FSO1.OpenTextFile(sPath, 1, False)
s1 = TS.ReadAll
TS1.Close
Set TS1 = Nothing
ExecuteGlobal s1
Set FSO1 = Nothing
End Sub

Basically, you call ExecuteGlobal on any string to include
it into the global scope of your script. I often use the above
as "IncludeClass", saving whole classes to .VBS files and then
adding them where needed.
Post by Jake
I have som common procedures in my logon files and I want to gather all
these in a file general-logon.vbs
Then I want to make user group specific logon files which all starts by
including this general-logon.vbs file at the top.
What is the syntax for including a vbs file in this scenario?
Jake
mr_unreliable
2008-01-25 16:58:45 UTC
Permalink
Post by Jake
What is the syntax for including a vbs file in this scenario?
Jake, if you are willing to compromise your requirements
a bit, and use a "wsf" file instead of a vbs file, then
you may include other scripts with a "one-liner".
For example:

--- <code> ---
<?XML version="1.0" standalone="yes" encoding="iso-8859-1" ?>
<job id="demoWSF">
<comment> This "includes" the cbt hookingini code... </comment>
<script language="VBScript" src="incOpenFileDlgDeclarations.vbs" ></script>

<script language="VBScript">
<![CDATA[
' ===================
' your script goes here...
' ===================


]]>
</script>
</job>
--- </code> ---

As usual, you can find the documentation for a "wsf" file
in the scripting documentation.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
Al Dunbar
2008-01-27 00:38:01 UTC
Permalink
Post by mr_unreliable
Post by Jake
What is the syntax for including a vbs file in this scenario?
Jake, if you are willing to compromise your requirements
a bit, and use a "wsf" file instead of a vbs file, then
you may include other scripts with a "one-liner".
--- <code> ---
<?XML version="1.0" standalone="yes" encoding="iso-8859-1" ?>
<job id="demoWSF">
<comment> This "includes" the cbt hookingini code... </comment>
<script language="VBScript" src="incOpenFileDlgDeclarations.vbs"
Post by Jake
</script>
<script language="VBScript">
<![CDATA[
' ===================
' your script goes here...
' ===================
]]>
</script>
</job>
--- </code> ---
As usual, you can find the documentation for a "wsf" file
in the scripting documentation.
Good advice to use a .wsf file. Our logon script is a .wsf that uses the
script tag to include files containing utility functions. We also use a
version of the "IncludeFile" subroutine to allow some site-specific
customization. One problem with IncludeFile is that routines loaded in that
manner can be difficult to debug. A further issue that we have been advised
of by a consultant from Microsoft is that there can be a significant amount
of overhead in terms of network traffic associated with processing separate
files located in the NETLOGON share, especially those that are in deeply
nested folder structures. If I had known that when I wrote the script, I
would have made it a bit more efficient by reducing the number of separate
files and simplifying how they are stored.

Anyway, it is not a problem for most of our users, but those coming in
through vpn connections and at sites with no DC wind up spending longer
waiting for the script to finish than they should have to.

/Al
Post by mr_unreliable
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
mr_unreliable
2008-01-28 18:11:50 UTC
Permalink
As for the difficulty in debugging "include files", yes it is.
But, generally speaking one ought to debug the include code
thoroughly (in the context of the main script), before
separating it out into a separate "include file".

As for the (lengthy) time required to retrieve the include
file from a server to satisfy the "wsf" file, one might also
assert that it would take about the same time to retrieve
that same code if used as previously recommended (readall,
eval).

Lastly, as a win98 user, I might also observe that your users
may already be in a "testy mood" at startup, having waited for
a relatively lengthy period for their systems (xp or vista)
to load. It is frankly surprising to me to see a much more
modern software system, on a hardware system that is running
more than 10x faster than my system -- take so much longer
to load...

cheers, jw
Al Dunbar
2008-01-29 04:18:39 UTC
Permalink
Post by mr_unreliable
As for the difficulty in debugging "include files", yes it is.
But, generally speaking one ought to debug the include code
thoroughly (in the context of the main script), before
separating it out into a separate "include file".
Given that subs and functions are not always quite as independent of each
other as we would like to think, due mainly to global variables, it can be
more of a problem to fully debug a subroutine.
Post by mr_unreliable
As for the (lengthy) time required to retrieve the include
file from a server to satisfy the "wsf" file, one might also
assert that it would take about the same time to retrieve
that same code if used as previously recommended (readall,
eval).
One might assert this, and one might be correct. My comments about the
networking overhead involved in a logon script accessing files from deeply
nested folders in the netlogon share did not discriminate between different
types of file access, whether static .wsf includes or dynamic readall/eval
includes.

That said, I suspect that the scripting engine would perform the static
includes in a manner at least theoretically more efficient than the typical
includefile function. Also, a poorly constructed script could include the
same file more than one in the dynamic case, but less likely so in the
static .wsf case.

Finally, .readall is problematic for large files. Better to use .read and
specify the length of the file as determined from the file object.
Post by mr_unreliable
Lastly, as a win98 user, I might also observe that your users
may already be in a "testy mood" at startup, having waited for
a relatively lengthy period for their systems (xp or vista)
to load. It is frankly surprising to me to see a much more
modern software system, on a hardware system that is running
more than 10x faster than my system -- take so much longer
to load...
Our users complain about that too. I usually ask them who manages their
Active Directory infrastructure at home with its multiple domain
controllers, time servers, DNS servers, file and print servers, and etc. Or
I ask them how quickly they are back up and running after a system hard
drive crashes irrecoverably. Most recognize the higher
availability/reliability as something they would gladly trade the speediness
of their home computers for.

/Al
mayayana
2008-01-29 14:31:14 UTC
Permalink
Post by mr_unreliable
Lastly, as a win98 user, I might also observe that your users
may already be in a "testy mood" at startup, having waited for
a relatively lengthy period for their systems (xp or vista)
to load. It is frankly surprising to me to see a much more
modern software system, on a hardware system that is running
more than 10x faster than my system -- take so much longer
to load...
It's ironic. It wasn't so long ago that we waited
8 seconds for a window to open because we were
waiting for Intel to come out with a faster processor.
Now the cheapest PC has many times the functionality
that most people need, and it's still a long wait. Microsoft
programmers are remarakbly talented at finding a use
for that functionality.

I've been playing with Windows Xtra Problems lately.
(I'm beginning to get a collection of PCs from people
who don't know any better than to replace them every
3 years, but I still do any serious work on 98.)

I find that XP is
capable of being quite zippy and of starting up nearly as
fast as 98. But it required a lot of research to get to
that. By removing the ridiculous PCHealth, and turning off
the vast majority of services (I've found 58 that I don't,
needmany of which are risky as well as unnecessary!),
and also turning off all of the kiddie GUI elements, XP is
as fast as 98 and better at handling a load. (I still haven't
decided whether I can get XP to where it's safe enough to
go online.)

One of the worst things I've found about XP is that MS
has got into some rather dubious design ideas. Windows
File Protection (PCHealth) and indexing service both cause
the hard disk to run on a regular basis and both are bad
ideas for most people. In a sense, XP is designed to cause
people to buy new PCs more often. After all, very few people
will fix a PC with a broken hard disk, and that constant activity
should kill the disk well before its time.

Many of the XP additions can be mildly helpful to
inexperienced people. PCHealth and System Restore are two
examples. But both of those things are also good examples
of dubious design ideas. Coming from Win98 and seeing
System Restore, auto. updates, etc. feels like going
from a finished OS to one that's always barely surviving.
It's amazing that people have become accustomed to a
system that's virtually defined as always being in crisis,
with constant patches being applied and the system being
"restored" whenever anything goes wrong.

Vista seems to be a whole different case, well beyond even
the issues with Xtra Problems. I read the other
day that it requires 15GB to install! I don't even know
what to say about that. But I'd bet the hardware people are
happy. If you visit the Vista group you'll find lots of people
who now think they need 2-4GB RAM to read their email. :)
mr_unreliable
2008-01-29 18:27:24 UTC
Permalink
Mayayana, it is interesting to note that one can speed up
winXP loading, by eliminating enough unnecessary "services".
This is reminiscent of the "de-crapification" script that
removes all those unwanted freebie craplets that come with
a new system, but goes one step deeper.

I will be saving your advice, if/when I ever need a new
system. The current one is 10 years old, and won't last
forever. Perhaps as a service to mankind (and womenkind,
sorry you feminists) you could write a script which would
remove all the unnecessary services and other stuff from
xp, to get it to startup faster.

But then, getting a system withOUT vista could be a problem.
MS is apparently not selling xp anymore to the public. I am
aware of a couple of "special situations", i.e., Dell-Business
will sell you a system with xp loaded -- because many businesses
have tried vista and after some lengthy evaluation refused to
adopt it. But support for xp will be dropped soon, and so
probably the opportunity to purchase a system with xp will
probably go away too. Could be my only option is to purchase
a new system with xp "pre-need", and store it away in a closet,
awaiting the demise of my faithful win98 system...

cheers, jw
mayayana
2008-01-29 19:22:52 UTC
Permalink
Post by mr_unreliable
Perhaps as a service to mankind (and womenkind,
sorry you feminists) you could write a script which would
remove all the unnecessary services and other stuff from
xp, to get it to startup faster.
I've already done that. It's a series of HTAs that comprise
a single utility. One page is all services options and another
is various handy tweaks. I just haven't got around to
finishing touches, so it's not online yet.
(But I'm happy to make it available to anyone who wants
to test it out.)
Post by mr_unreliable
But then, getting a system withOUT vista could be a problem.
MS is apparently not selling xp anymore to the public. I am
aware of a couple of "special situations", i.e., Dell-Business
will sell you a system with xp loaded -- because many businesses
have tried vista and after some lengthy evaluation refused to
adopt it. But support for xp will be dropped soon, and so
probably the opportunity to purchase a system with xp will
probably go away too. Could be my only option is to purchase
a new system with xp "pre-need", and store it away in a closet,
awaiting the demise of my faithful win98 system...
I built a new Win98 box awhile back, when it looked
like hardware options for Win9x might be getting thin.
And I bought a full version 98 CD when XP came out.
(I could see I wouldn't be wanting XP as soon as it was
released.) So I'm set for awhile. I was looking at laptops
recently, though, for a friend. Out of maybe 40 models
there seemed to be about 5 or 6 with XP, but they were
the more pricey models. Of the laptops with Vista, not
all can have XP put onto them without trouble, due to
some having SATA disk connections, graphics without
XP drivers, etc. It should be fairly cheap to make a new
box and buy an OEM XP CD, but of course then you're
at the mercy of MS if you have hardware problems.
mr_unreliable
2008-01-29 23:17:56 UTC
Permalink
Maybe the answer for me (when existing win98 system
goes to the big hardware recycling depot in the sky)
is to just get whatever vista system looks like the
"best buy" and then install VMWare (or similiar clone),
and then run my win98 (and ofc2k, and IE6) under that.

cheers, jw
mayayana
2008-01-30 14:36:09 UTC
Permalink
This post might be inappropriate. Click to display it.
Paul Randall
2008-01-30 17:44:37 UTC
Permalink
Post by mayayana
* .Net has bloated up to 5 versions, with compatibility issues,
even though it still seems to be used only on Windows servers.
(After all, who wants to write slow software that drags along
100 MB of support files?) Starting with .Net 3 it only runs on
XP SP2+. But wait - The .Net 3 editor allows people to write
code for .Net 2, so that their .Net 3 investment won't go to
waste!
.Net only used on Windows servers? I think it is required for
Microsoft Streets & Trips (2007 and perhaps other versions). Of
course, maybe it is just required, but never used ;-)

-Paul Randall
mayayana
2008-01-30 23:21:49 UTC
Permalink
Post by Paul Randall
.Net only used on Windows servers? I think it is required for
Microsoft Streets & Trips (2007 and perhaps other versions). Of
course, maybe it is just required, but never used ;-)
Yes, it is used for a few things. Paint.net uses it.
Drive Image uses it. (Though I'm not sure anyone
still uses Drive Image. :) I've had the impression
that Microsoft is finding uses for it to provide more
credibility.

For anyone interested, there's a somewhat interesting
article here about how silverlight, volta and .Net relate
to each other:
http://www.betanews.com/article/Microsoft_ties_highlevel_code_to_Web_develop
ment_with_Volta/1197045064

It has this very telling quote from the head of the
Volta project:

"[Volta] actually puts .NET to use in the way it was originally intended,
making .NET into an unquestionable contender against Java in a way that
developers can no longer ignore."
Al Dunbar
2008-01-31 03:20:42 UTC
Permalink
Post by mayayana
Post by mr_unreliable
Lastly, as a win98 user, I might also observe that your users
may already be in a "testy mood" at startup, having waited for
a relatively lengthy period for their systems (xp or vista)
to load. It is frankly surprising to me to see a much more
modern software system, on a hardware system that is running
more than 10x faster than my system -- take so much longer
to load...
It's ironic. It wasn't so long ago that we waited
8 seconds for a window to open because we were
waiting for Intel to come out with a faster processor.
Now the cheapest PC has many times the functionality
that most people need, and it's still a long wait. Microsoft
programmers are remarakbly talented at finding a use
for that functionality.
I've been playing with Windows Xtra Problems lately.
(I'm beginning to get a collection of PCs from people
who don't know any better than to replace them every
3 years, but I still do any serious work on 98.)
That last statement is very interesting...
Post by mayayana
I find that XP is
capable of being quite zippy and of starting up nearly as
fast as 98. But it required a lot of research to get to
that. By removing the ridiculous PCHealth, and turning off
the vast majority of services (I've found 58 that I don't,
needmany of which are risky as well as unnecessary!),
and also turning off all of the kiddie GUI elements, XP is
as fast as 98 and better at handling a load. (I still haven't
decided whether I can get XP to where it's safe enough to
go online.)
I have xp media edition at home and find its performance abysmal. But most
of the unnecessary things burning away resources and "excess" capacity seem
to be the unwanted additional free/demo ware.
Post by mayayana
One of the worst things I've found about XP is that MS
has got into some rather dubious design ideas. Windows
File Protection (PCHealth) and indexing service both cause
the hard disk to run on a regular basis and both are bad
ideas for most people. In a sense, XP is designed to cause
people to buy new PCs more often. After all, very few people
will fix a PC with a broken hard disk, and that constant activity
should kill the disk well before its time.
Many of the XP additions can be mildly helpful to
inexperienced people. PCHealth and System Restore are two
examples. But both of those things are also good examples
of dubious design ideas. Coming from Win98 and seeing
System Restore, auto. updates, etc. feels like going
from a finished OS to one that's always barely surviving.
It's amazing that people have become accustomed to a
system that's virtually defined as always being in crisis,
with constant patches being applied and the system being
"restored" whenever anything goes wrong.
While it may seem that XP is in a state of constant crisis, our experience
is that when we converted from 98 to XP we got lots of support calls up
front because things were different, but they dwindled quickly. We have
systems out there that have been in virtual continual use for three or four
years with no real problems. The number of technician trips to the desktop
went way down, and we feel that is because of the stability of our
configuration. For one thing, no user is ever given local admin privs.
Post by mayayana
Vista seems to be a whole different case, well beyond even
the issues with Xtra Problems. I read the other
day that it requires 15GB to install! I don't even know
what to say about that. But I'd bet the hardware people are
happy. If you visit the Vista group you'll find lots of people
who now think they need 2-4GB RAM to read their email. :)
/Al
mayayana
2008-01-31 16:00:02 UTC
Permalink
This post might be inappropriate. Click to display it.
Al Dunbar
2008-02-01 21:44:37 UTC
Permalink
Post by mayayana
Post by Al Dunbar
While it may seem that XP is in a state of constant crisis, our experience
is that when we converted from 98 to XP we got lots of support calls up
front because things were different, but they dwindled quickly. We have
systems out there that have been in virtual continual use for three or
four
Post by Al Dunbar
years with no real problems. The number of technician trips to the desktop
went way down, and we feel that is because of the stability of our
configuration. For one thing, no user is ever given local admin privs.
I'm looking at it from a point of view of someone
who owns their PC,
Yes, this is obviously a significant distinction.
Post by mayayana
which highlights a big issue with
NT systems that MS has blurred over, and as a result
gets blurred over in these discussions: Even though
MS made a "Home" version of XP, all of their versions
are basically the same thing. They're all network
workstations.
I have no idea why they bothered with a "home" version of XP, other than
making it an easier sale into that market. Of course, XP home is not
*really* a network workstation, as it cannot actually *join* a domain
Post by mayayana
On a network you usually can't trust the person
sitting at the PC, but you can trust the network itself.
The person using the PC generally owns it or is trusted,
but the Internet is risky.
That is certainly an interesting way to look at it. Unfortunately, however,
since the internet is risky, home users should be as concerned about running
with least privilege - not because they themselves cannot be trusted, but
because the internet cannot be trusted with their privileges.
Post by mayayana
It seems that with XP, MS has designed something that's
better suited as a workstation than Win9x is.
Most definitely...
Post by mayayana
(And it's even
maybe a little safer for home use if people are completely
non-techie, with it's rudimentary firewall and auto. update.)
So "in the enterprise" you get a machine that allows you to
limit user control and is better designed for intranet use, but
home and small office users get a machine with loads of
unnecessary, poorly documented, and often risky services
running. They also get a machine that works against them.
As someone who owns their own PC, my biggest complaint
with XP (well, after the product activation, bloat and
spyware :) is that it lies to me. And that adds a lot of wasted
time and confusion to everything. There's a constant sense
that MS views the customer as an adversary and has decided
to appoint themselves as default system administrator for
anyone who doesn't already have one. For instance, Windows
File Protection could have been designed to simply show a
msgbox that says, "You may not delete that file due to file
security. Click here if you would like to understand and/or adjust
file security settings." Instead, WFP lets you delete the file,
then puts it back again from a secret stash! Usually after you've
closed the folder. No explanation. Little documentation. No
configuration. The ability to stop WFP altogether is basically a
"secret tweak".
I wouldn't say that XP lies to you, just that it sometimes makes mistakes in
what it says. error messages almost always describe the error from the
computer's point of view rather than from the user's. While some software
developers know this better than others, it can still be difficult for all
diagnostics to make sense.

On my XP media system, most of these problems come from the unwanted extras
thrown onto the system by the OEM. So my wife logs in and is told that
*something* (even I do not know what it is referring to) is currently being
processed by "Al" - do you want to take this over? First, the answer is
never YES, as whatever the process, her account lacks the privs to do this.
And when I answer YES using another privileged account, well, I still do not
know what is actually happening.
Post by mayayana
I think that at the root of these problems is mixed motives
on the part of MS. They want to make a better, more secure
OS. They also want to reduce support costs. They also want to
satisfy corporate customers. They also want to phase out
3rd-party access to the API and switch their customers over
to a services box. They also want to leverage their user base
to gain some control over the Internet and profit from the
sale of so-called "art". (Music and films.)
But they can't be all those things. Some people might want MS
services, but other people just want a PC that works the way
they expect. Even MS seems to be getting confused about what
the product is.
LOL, and just today I heard they were offering tens of billions to purchase
Yahoo! I guess MSDN search never really did catch up with google!
Post by mayayana
Apropos of all that, I saw a telling article at the Register the other
day, where they said that the French police are replacing XP with
Ubuntu. One of the reasons they gave for the switch is "gaining
control of the software".
Yes, sometimes it is hard to figure out who is controlling who on your own
PC.

/Al
Bob O`Bob
2008-02-02 06:02:49 UTC
Permalink
Post by Al Dunbar
I have xp media edition at home and find its performance abysmal. But most
of the unnecessary things burning away resources and "excess" capacity seem
to be the unwanted additional free/demo ware.
Yeah, my roommate and I have each one of those.
Refurbished Compaqs, I got cheap from woot.com

Got any good references to crapware/bloat removers?



Bob
--
Al Dunbar
2008-02-03 18:43:07 UTC
Permalink
Post by Bob O`Bob
Post by Al Dunbar
I have xp media edition at home and find its performance abysmal. But
most of the unnecessary things burning away resources and "excess"
capacity seem to be the unwanted additional free/demo ware.
Yeah, my roommate and I have each one of those.
Refurbished Compaqs, I got cheap from woot.com
Got any good references to crapware/bloat removers?
Sorry, no. a few years ago I googled someone's page who listed the things
that should be (manually) de-installed from an HP pavilion media centre PC.
It helped, but somehow it seems to have gotten junked up with more bloat.

/Al
mr_unreliable
2008-02-04 17:50:12 UTC
Permalink
Post by Bob O`Bob
Yeah, my roommate and I have each one of those.
Refurbished Compaqs, I got cheap from woot.com
Got any good references to crapware/bloat removers?
hi Bob-O-Bob,

If you read back through this thread, you will find that
"mayayana" may have already done what you want.

--- <quote> ---
I've already done that. It's a series of HTAs that comprise
a single utility. One page is all services options and another
is various handy tweaks. I just haven't got around to finishing
touches, so it's not online yet. (But I'm happy to make it
available to anyone who wants to test it out.)
--- </quote> ---

So there's a possibility he has done the work. You have
two choices, (1) if in a hurry contact him directly, or
(2) if willing to wait, mayayana will probably eventually
post that work on his website.

cheers, jw

note: mayayana seems to be betraying his English (or possibly
Canadian) origins with that "haven't got around" instead of
"haven't gotten around"... The English think that "gotten"
sounds archaic, whereas Americans think that "whilst" sounds
archaic.
mayayana
2008-02-04 21:54:32 UTC
Permalink
Post by mr_unreliable
note: mayayana seems to be betraying his English (or possibly
Canadian) origins with that "haven't got around" instead of
"haven't gotten around"... The English think that "gotten"
sounds archaic, whereas Americans think that "whilst" sounds
archaic.
American. Sorry to blow your theory. I wasn't
aware of those particular language quirks, but
I'm from New England, so that may be a third
case. We seem to have more leftover British language
habits than most of the US.

I didn't do anything to clean out "shovelware" in XP
with the utility I'm working on.

I'm just trying to clean up the Microsoft default configuration.
I can't imagine any 3rd-party program that would do
a reasonable job of OEM cleanup. It just has to be
done by hand, all of a piece. After all, a cleaner program
might remove well-known ad programs, or nonsense like
XDrive. But will it also remove "Online Services"? Or a useless
90-day demo of some Symantec crap? Or Microsoft's useless
FrontPage and Office folders, Media Player, Messenger, and
whatever else they feel they just have to put into Program
Files without asking? I suspect that any cleaner available will
"respect" such corporate "kosher" shovelware. (No,
I'm not Jewish, either. :)

I do cleanup once, thoroughly, then install
software, do all the detailed configuration, and image
the new system. Then I never have to see the junk
again. And I never have to re-install the software again.
To my mind, spyware hunters, crapware
removers, Registry cleaners, etc., are all in the same
category: just more layers of unnecessary junk.
mayayana
2008-02-04 21:59:46 UTC
Permalink
I must say, I get a kick out of the way that people
seem to deal with their PCs. We've got a group of people
here who are very well informed and tuned in when it
comes to their work PCs, and Al just got through talking
about the importance of running as a limited user, even
on home PCs. But then most people apparently go home
and just live with whatever their home PC has installed
on it: bloat, Microsoft spyware, 3rd-party spyware, risky
services, etc. :)

Loading...