Is it possible to use a predefined variable for group name as
As are we all ...
Ah, that is kind of what I thought. The idea makes sense, as it can be
devilishly hard to change literal constants throughout a script without
causing yourself some grief.
You certainly can. But I would recommend that all of these values be defined
at the very top of your script so you will be sure to make all of the
required changes when you modify the script for the next run.
Here is your first mistake - a simple one and fairly common for beginners
and/or people converting from other scripting technologies such as kixtart.
Putting the name of a variable in parenthesis causes it to be treated
literally. That is it becomes a string whose value is, coincidentally, the
same as the NAME of a variable. But it does not reference that variable in
any way. As written, your script will set the default printer when it finds
a group whose name is, literally, "GroupName1"; it will NOT do anything when
it runs across a group whose name is the same as the value assigned to the
variable whose name is GroupName1.
That is a rather wordy explanation that may or may not help. Here is a
simpler one: when you want to work with the value represented by a variable,
DO NOT ENCLOSE IT IN QUOTES.
If you change your line above to this:
I suspect that you will find that it works in the way you desire.
Note that even if you DO define the variable, the above works because
"prnDefault WA1-IT-01" is the actual value you are looking for.
No. In fact what you are trying to do is a good thing. You just need a
little help with some of the details. Make the change I suggested above to
the case statement, and let us know how it goes.
One other question, in anticipation of what might be another
misunderstanding on your part: I see you have given your variables slightly
different names this time from the first post you made, strUNCPrinter1 and
GroupName1 instead of strUNCPrinter and GroupName. What, in your mind, does
the "1" represent? /Al
|