How you you figure out what goup a user account belongs to within a batch file?

  • Thread starter Bloke at the pennine puddle (Replace n.a.v.d with
  • Start date
B

Bloke at the pennine puddle (Replace n.a.v.d with

I'm totally baffled on how to do something under Windows 2000 and
equally under Widnows 98.

How, within a batch file, can I determine what groups a the logged in
user belongs to? Under Novell, within a login script it's as easy as
.....

if member of "SOME_GROUP" then <do the action>

Under Windows 2003 server, Windows 2000 and Windows 98 I'm am truly
baffled.

Can anyone assist? This must be something that loads of people would
want to do, so as to use a login script and/or batch file to perform
specific actions depending to what groups a user account belongs to.
 
B

Bill Stewart

Bloke at the pennine puddle said:
I'm totally baffled on how to do something under Windows 2000 and equally
under Widnows 98.

How, within a batch file, can I determine what groups a the logged in
user belongs to?

(Cross-posting removed)

I recommend using the KiXtart scripting language for logon scripts. It's a
simple, free-form scripting language that doesn't need anything to be
installed on the client.

www.kixtart.org

HTH,

Bill
 
R

Ray at

The easy way is by using the ifmember.exe from the Resource Kit. But, you
can also do this, I suppose:

set /a x=0
for /f %%j in ('net user test ^| find /i "group name"') do (set /a x=x+1)
if %x% GTR 0 (your commands)

Ray at work




"Bloke at the pennine puddle (Replace n.a.v.d with vodafone.net.)"
 
M

Matthias Tacke

Bloke at the pennine puddle (Replace n.a.v.d with vodafone.net.) said:
I'm totally baffled on how to do something under Windows 2000 and
equally under Widnows 98.

How, within a batch file, can I determine what groups a the logged in
user belongs to? Under Novell, within a login script it's as easy as
....

if member of "SOME_GROUP" then <do the action>

Under Windows 2003 server, Windows 2000 and Windows 98 I'm am truly
baffled.

Can anyone assist? This must be something that loads of people would
want to do, so as to use a login script and/or batch file to perform
specific actions depending to what groups a user account belongs to.

You are right with that assumption. And a proper way is to ask google:
http://www.google.com/groups?q=if+member+group:microsoft.public.win2000.cmdprompt.admin


The w2k reskit contains ifmember.exe (payware)

And did you notice the output of :

net user %username% |find "*"

HTH
 
T

Tom

"Bloke at the pennine puddle (Replace n.a.v.d with vodafone.net.)"
I'm totally baffled on how to do something under Windows 2000 and
equally under Widnows 98.

How, within a batch file, can I determine what groups a the logged in
user belongs to? Under Novell, within a login script it's as easy as
....

if member of "SOME_GROUP" then <do the action>

Under Windows 2003 server, Windows 2000 and Windows 98 I'm am truly
baffled.

Can anyone assist? This must be something that loads of people would
want to do, so as to use a login script and/or batch file to perform
specific actions depending to what groups a user account belongs to.


net user <USERNAME> | find /I "admin" && echo yes || echo no
 
T

Tom

Bloke at the pennine puddle (Replace n.a.v.d with vodafone.net.) said:
I'm totally baffled on how to do something under Windows 2000 and
equally under Widnows 98.

How, within a batch file, can I determine what groups a the logged in
user belongs to? Under Novell, within a login script it's as easy as
....

if member of "SOME_GROUP" then <do the action>

Under Windows 2003 server, Windows 2000 and Windows 98 I'm am truly
baffled.

Can anyone assist? This must be something that loads of people would
want to do, so as to use a login script and/or batch file to perform
specific actions depending to what groups a user account belongs to.


http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/ifmember-o..asp
 
R

Reinhardt Kern

"Bloke at the pennine puddle (Replace n.a.v.d with
vodafone.net.) said:
I'm totally baffled on how to do something under Windows 2000 and
equally under Widnows 98.

How, within a batch file, can I determine what groups a the logged in
user belongs to? Under Novell, within a login script it's as easy as
....

if member of "SOME_GROUP" then <do the action>

Under Windows 2003 server, Windows 2000 and Windows 98 I'm am truly
baffled.

I also highly recommend http://www.kixtart.org.

With Kix you can create one single logon script, that works for
Win98 and Win2000.

I don't love VBscript, because it highly depends on the various
versions of the installed scripting objects.

Just download the Kix documentation and give it a try.

Reinhardt
 
B

Bloke at the pennine puddle (Replace n.a.v.d with

Thanks Ray, but Windows 98 does not have `NET USER` available, it also
does not have the nice extended IF statement.

I'm desparate to find some way of checking the what group a user
belongd to using a batch file under Windows 98 and Windows 95. I can
already create a `USERNAME` environment variable so the batch file
knows who's signed in, just what groups does that users belong to.

I don't have a choice to upgrade the workstations just yet. A custom
designed legacy application just goes not like Windows NT or better.

There gotta be some way to perform this comparison under Win 9x?

Anyone know how?
 
A

Al Dunbar [MS-MVP]

Bill Stewart said:
(Cross-posting removed)

I recommend using the KiXtart scripting language for logon scripts. It's a
simple, free-form scripting language that doesn't need anything to be
installed on the client.

Not needed, but recommended nonetheless. By the docs, as I recall.

/Al
 
A

Al Dunbar [MS-MVP]

"Bloke at the pennine puddle (Replace n.a.v.d with vodafone.net.)"
sp

Got it. Thanks. Question is, how well does it work with Windows 98?

The headache I have got is that the solution has got to work with
Windows 98 or lower as well as a solution for Windows NT or better.

I've inherited a mess.

As another poster suggested, kixtart may be a good choice for you. Mind you,
we found that the ingroup function did not work exactly as expected. I don't
recall the details (having switched to WSH), but in order for group
membership testing to work, you need to include two or three dll's. The can
be on the DC, but that may give bandwidth issues. Also and active directory
account in an active directory group was not detected as a member of an NT4
domain local group that had the AD global group as member.

/Al
 
E

Ed Siff

The only way you're going to get that done is to use Kixtart's ingroup
command in a login script. See http://www.kixtart.org.

IF INGROUP ("whatever")
set group=whatever

Then your batch file could use the %group% environment variable


Ed
 
B

Bill Stewart

Bloke at the pennine puddle said:
Got it. Thanks. Question is, how well does it work with Windows 98?

It doesn't. That's why I recommended KiXtart. But for best results on Win98
clients, you will need to install the included RPC service.

Bill
 
A

Al Dunbar [MS-MVP]

Bill Stewart said:
Yes. Use KiXtart.

As I pointed out earlier (in this thread?), KiXtart's ingroup function does
NOT work in all cases as one might assume (and, yes, we installed the RPC
service). In our case it failed to note an active directory account as a
member of a local NT4 group that contained a global group from the active
directory name that contained the user account. We switched to WSH in order
to accommodate this currently show-stopping limitation (among other
reasons). As a result, we did not do further testing to find other
combinations on which KiXtart might fail, such as, perhaps, multiple AD
domains. I would recommend that testing be done in the target environment on
all possible combinations that you expect ingroup to work for.

/Al
 
D

David Wang [Msft]

I'd like to voice an opinion on:
"I don't have a choice to upgrade the workstations just yet. A custom
designed legacy application just goes not like Windows NT or better."

A legacy program does NOT necessarily prevent you from upgrading the
workstation OS. You can
1. Upgrade the workstation OS to something modern and manageable like XP Pro
2. Have the necessary workstations run Virtual PC with an image of Windows9x
to handle this program
-- Assuming that these programs do not need dedicated HW that is not
emulated by Virtual PC, in which case you're stuck.

Once you virtualize a legacy application, you can take it forward with you
and unlock the workstation's OS from the legacy application. If in the
future you move away from the legacy application, just stop running the
Virtual PC image, and you're done.

--
//David
IIS
This posting is provided "AS IS" with no warranties, and confers no rights.
//
"Bloke at the pennine puddle (Replace n.a.v.d with vodafone.net.)"
Thanks Ray, but Windows 98 does not have `NET USER` available, it also
does not have the nice extended IF statement.

I'm desparate to find some way of checking the what group a user
belongd to using a batch file under Windows 98 and Windows 95. I can
already create a `USERNAME` environment variable so the batch file
knows who's signed in, just what groups does that users belong to.

I don't have a choice to upgrade the workstations just yet. A custom
designed legacy application just goes not like Windows NT or better.

There gotta be some way to perform this comparison under Win 9x?

Anyone know how?
 
B

Bill Stewart

David Wang said:
Once you virtualize a legacy application, you can take it forward with
you and unlock the workstation's OS from the legacy application. If in
the future you move away from the legacy application, just stop running
the Virtual PC image, and you're done.

This is a good suggestion, but depending on the environment and
organization this solution may not be monetarily feasible. You would have
to license XP and VMWare, Virtual PC, or whatever, just to run a legacy app
(and maybe on old hardware? Do we need all new PCs just to run XP and a
virtualizer?).

Regards,

Bill
 
D

David Wang [Msft]

If the organization has no intentions of moving off their existing platform,
then sure, introducing Virtual PC to handle legacy is a waste of money.
However, if the organization is intending to move forward but the legacy app
is holding them back, Virtual PC is a trivial cost to unlock the
organization from both the legacy HW and OS.

My working assumption is that an organization would like to move off of
Windows98 to something like Windows XP, but the legacy App is preventing the
move. In such a case, the only extra cost would be the Virtual PC license
and is almost like purchasing a license to remove the lock of the legacy app
and any extra special IT support.

Presumably, you already hold a license for the legacy OS and App. Also, you
already plan to hold a license for the newer OS and HW -- it's the legacy
App that's holding you from actually making the move. So the extra cost is
just Virtual PC itself and what it buys is freedom to move forward.

--
//David
IIS
This posting is provided "AS IS" with no warranties, and confers no rights.
//
David Wang said:
Once you virtualize a legacy application, you can take it forward with
you and unlock the workstation's OS from the legacy application. If in
the future you move away from the legacy application, just stop running
the Virtual PC image, and you're done.

This is a good suggestion, but depending on the environment and
organization this solution may not be monetarily feasible. You would have
to license XP and VMWare, Virtual PC, or whatever, just to run a legacy app
(and maybe on old hardware? Do we need all new PCs just to run XP and a
virtualizer?).

Regards,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top