Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Command scripts

Reply
Thread Tools Display Modes

Command scripts

 
 
Tcs
Guest
Posts: n/a

 
      07-14-2009
I'm dealing with logon scripts, and am trying to keep this simple, if
possible.

I'd like to be able to tell if the machine I'm logging into is a
server, vs a client. There doesn't seem to be any variable available
that designates such a thing. I suppose I could test for a particular
server program, but I'm not sure what will always be there, and isn't
dependent upon what components have been installed.

Anyone have any suggestions/thoughts/ideas?

Thanks in advance,

Tom
 
Reply With Quote
 
 
 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      07-14-2009

"Tcs Somewhere" <at> wrote in message
news:...
> I'm dealing with logon scripts, and am trying to keep this simple, if
> possible.
>
> I'd like to be able to tell if the machine I'm logging into is a
> server, vs a client. There doesn't seem to be any variable available
> that designates such a thing. I suppose I could test for a particular
> server program, but I'm not sure what will always be there, and isn't
> dependent upon what components have been installed.
>
> Anyone have any suggestions/thoughts/ideas?
>
> Thanks in advance,
>
> Tom


You can use DomainRole property of the Win32_ComputerSystem class of WMI.
See this link from the Script Center:

http://www.microsoft.com/technet/scr..._srv_yzhs.mspx

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a

 
      07-14-2009

"Tcs Somewhere" <at> wrote in message
news:...
> I'm dealing with logon scripts, and am trying to keep this simple, if
> possible.
>
> I'd like to be able to tell if the machine I'm logging into is a
> server, vs a client. There doesn't seem to be any variable available
> that designates such a thing. I suppose I could test for a particular
> server program, but I'm not sure what will always be there, and isn't
> dependent upon what components have been installed.
>
> Anyone have any suggestions/thoughts/ideas?
>
> Thanks in advance,
>
> Tom


Perhaps something as simple as the "ver" console command will meet your
requirements.


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      07-14-2009

"Pegasus [MVP]" <> wrote in message
news:#...
>
> "Tcs Somewhere" <at> wrote in message
> news:...
>> I'm dealing with logon scripts, and am trying to keep this simple, if
>> possible.
>>
>> I'd like to be able to tell if the machine I'm logging into is a
>> server, vs a client. There doesn't seem to be any variable available
>> that designates such a thing. I suppose I could test for a particular
>> server program, but I'm not sure what will always be there, and isn't
>> dependent upon what components have been installed.
>>
>> Anyone have any suggestions/thoughts/ideas?
>>
>> Thanks in advance,
>>
>> Tom

>
> Perhaps something as simple as the "ver" console command will meet your
> requirements.


Perhaps a more succinct result can be had by extracting the "computer role"
value displayed by the "net accounts" command, i.e.:

for /f "tokens=3" %F in ('net accounts ^| find /i "computer role:"') do (set
role=%F)

/Al


 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a

 
      07-15-2009

"Al Dunbar" <> wrote in message
news:...
>
> "Pegasus [MVP]" <> wrote in message
> news:#...
>>
>> "Tcs Somewhere" <at> wrote in message
>> news:...
>>> I'm dealing with logon scripts, and am trying to keep this simple, if
>>> possible.
>>>
>>> I'd like to be able to tell if the machine I'm logging into is a
>>> server, vs a client. There doesn't seem to be any variable available
>>> that designates such a thing. I suppose I could test for a particular
>>> server program, but I'm not sure what will always be there, and isn't
>>> dependent upon what components have been installed.
>>>
>>> Anyone have any suggestions/thoughts/ideas?
>>>
>>> Thanks in advance,
>>>
>>> Tom

>>
>> Perhaps something as simple as the "ver" console command will meet your
>> requirements.

>
> Perhaps a more succinct result can be had by extracting the "computer
> role" value displayed by the "net accounts" command, i.e.:
>
> for /f "tokens=3" %F in ('net accounts ^| find /i "computer role:"') do
> (set role=%F)
>
> /Al


Nice one - I had forgotten about this none!


 
Reply With Quote
 
F. Dunoyer
Guest
Posts: n/a

 
      07-15-2009
Al Dunbar a écrit :
> "Pegasus [MVP]" <> wrote in message
> news:#...
>>
>> "Tcs Somewhere" <at> wrote in message
>> news:...
>>> I'm dealing with logon scripts, and am trying to keep this simple, if
>>> possible.
>>>
>>> I'd like to be able to tell if the machine I'm logging into is a
>>> server, vs a client. There doesn't seem to be any variable available
>>> that designates such a thing. I suppose I could test for a particular
>>> server program, but I'm not sure what will always be there, and isn't
>>> dependent upon what components have been installed.
>>>
>>> Anyone have any suggestions/thoughts/ideas?
>>>
>>> Thanks in advance,
>>>
>>> Tom

>>
>> Perhaps something as simple as the "ver" console command will meet your
>> requirements.

>
> Perhaps a more succinct result can be had by extracting the "computer role"
> value displayed by the "net accounts" command, i.e.:
>
> for /f "tokens=3" %F in ('net accounts ^| find /i "computer role:"') do (set
> role=%F)
>
> /Al


Nice ! but be careful : a DC is not a "SERVER"

--
François Dunoyer
Astuces pour Windows : http://fds.mvps.org/ta/
Site perso : http://www.fdunoyer.net
Blog : http://fds34.spaces.live.com/


 
Reply With Quote
 
Mark D. MacLachlan
Guest
Posts: n/a

 
      07-15-2009
Give this a try.

Code:
Dim wshShell, wshNetwork
Dim strComputerName, objComputer

' Create Global Objects
Set wshNetwork = CreateObject("WScript.Network")

' Initialize Variables
strComputerName = wshNetwork.ComputerName

strDN = GetDN(strComputerName)

Set objComputer = GetObject("LDAP://" & strDN)
If Instr(objComputer.operatingSystem,"Server") Then
WScript.Echo "Server Found"
Else
WScript.Echo "Not A Server"
End If


Function GetDN(strComputerName)
' Use the NameTranslate object to convert the NT name of the computer to
' the Distinguished name required for the LDAP provider. Computer names
' must end with "$". Returns comma delimited string to calling code.
' Name translate thanks to Richard Meuller

Dim objTrans, objDomain
' Constants for the NameTranslate object.
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

Set objTrans = CreateObject("NameTranslate")
Set objDomain = getObject("LDAP://rootDse")
objTrans.Init ADS_NAME_INITTYPE_GC, ""
objTrans.Set ADS_NAME_TYPE_NT4, wshNetwork.UserDomain & "\" _
& strComputerName & "$"
GetDN = objTrans.Get(ADS_NAME_TYPE_1779)
'Set DN to upper Case
GetDN = UCase(GetDN)
End Function
 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      07-15-2009

"F. Dunoyer" <wdunoyer-nimportequoi@laposte~.net> wrote in message
news:...
> Al Dunbar a écrit :
>> "Pegasus [MVP]" <> wrote in message
>> news:#...
>>>
>>> "Tcs Somewhere" <at> wrote in message
>>> news:...
>>>> I'm dealing with logon scripts, and am trying to keep this simple, if
>>>> possible.
>>>>
>>>> I'd like to be able to tell if the machine I'm logging into is a
>>>> server, vs a client. There doesn't seem to be any variable available
>>>> that designates such a thing. I suppose I could test for a particular
>>>> server program, but I'm not sure what will always be there, and isn't
>>>> dependent upon what components have been installed.
>>>>
>>>> Anyone have any suggestions/thoughts/ideas?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Tom
>>>
>>> Perhaps something as simple as the "ver" console command will meet your
>>> requirements.

>>
>> Perhaps a more succinct result can be had by extracting the "computer
>> role" value displayed by the "net accounts" command, i.e.:
>>
>> for /f "tokens=3" %F in ('net accounts ^| find /i "computer role:"') do
>> (set role=%F)
>>
>> /Al

>
> Nice ! but be careful : a DC is not a "SERVER"


I'm not sure if you mean that a DC returns a value of "DC", not "SERVER", or
if you have non-server O/S systems performing the DC role. Like the "VER"
method, this gives you information that differentiates computers in some
way. If not in exactly the way one might expect, it still might allow the
desired information to be deduced.

I have not tried this on computers having every possible combination of
roles. In our environment it is safe to assume that anything not reporting
itself as "WORKSTATION" would be some sort of server. Some people have also
assumed that if the first character in the computername is "S", then it is a
server, as that was part of our original naming convention. Of course, code
based on that assumption is broken now...

Of course, it all boils down to what differentiates "servers" from "clients"
in the OP's environment.


/Al


 
Reply With Quote
 
F. Dunoyer
Guest
Posts: n/a

 
      07-16-2009

Al Dunbar a écrit :
> "F. Dunoyer" <wdunoyer-nimportequoi@laposte~.net> wrote in message
> news:...
>> Al Dunbar a écrit :
>>> "Pegasus [MVP]" <> wrote in message
>>> news:#...
>>>>
>>>> "Tcs Somewhere" <at> wrote in message
>>>> news:...
>>>>> I'm dealing with logon scripts, and am trying to keep this simple, if
>>>>> possible.
>>>>>
>>>>> I'd like to be able to tell if the machine I'm logging into is a
>>>>> server, vs a client. There doesn't seem to be any variable available
>>>>> that designates such a thing. I suppose I could test for a particular
>>>>> server program, but I'm not sure what will always be there, and isn't
>>>>> dependent upon what components have been installed.
>>>>>
>>>>> Anyone have any suggestions/thoughts/ideas?
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> Tom
>>>>
>>>> Perhaps something as simple as the "ver" console command will meet your
>>>> requirements.
>>>
>>> Perhaps a more succinct result can be had by extracting the "computer
>>> role" value displayed by the "net accounts" command, i.e.:
>>>
>>> for /f "tokens=3" %F in ('net accounts ^| find /i "computer role:"') do
>>> (set role=%F)
>>>
>>> /Al

>>
>> Nice ! but be careful : a DC is not a "SERVER"

>
> I'm not sure if you mean that a DC returns a value of "DC", not "SERVER", or
> if you have non-server O/S systems performing the DC role. Like the "VER"
> method, this gives you information that differentiates computers in some way.
> If not in exactly the way one might expect, it still might allow the desired
> information to be deduced.


>
> I have not tried this on computers having every possible combination of
> roles. In our environment it is safe to assume that anything not reporting
> itself as "WORKSTATION" would be some sort of server. Some people have also
> assumed that if the first character in the computername is "S", then it is a
> server, as that was part of our original naming convention. Of course, code
> based on that assumption is broken now...
>
> Of course, it all boils down to what differentiates "servers" from "clients"
> in the OP's environment.
>

I Think that the test of "Workstation" is a better way
On my own server (French 2003 entreprise DC) the value is : "PRINCIPAL"
(primary)

--
François Dunoyer
Quelques liens pour Windows : http://fds.mvps.org/AdressesInternets.htm
Site perso : http://fds.mvps.org
Blog : http://fds34.spaces.live.com/


 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      07-16-2009


"F. Dunoyer" <wdunoyer-nimportequoi@laposte~.net> wrote in message
news:...
> Al Dunbar a écrit :
>> "F. Dunoyer" <wdunoyer-nimportequoi@laposte~.net> wrote in message
>> news:...
>>> Al Dunbar a écrit :
>>>> "Pegasus [MVP]" <> wrote in message
>>>> news:#...
>>>>>
>>>>> "Tcs Somewhere" <at> wrote in message
>>>>> news:...
>>>>>> I'm dealing with logon scripts, and am trying to keep this simple, if
>>>>>> possible.
>>>>>>
>>>>>> I'd like to be able to tell if the machine I'm logging into is a
>>>>>> server, vs a client. There doesn't seem to be any variable available
>>>>>> that designates such a thing. I suppose I could test for a
>>>>>> particular
>>>>>> server program, but I'm not sure what will always be there, and isn't
>>>>>> dependent upon what components have been installed.
>>>>>>
>>>>>> Anyone have any suggestions/thoughts/ideas?
>>>>>>
>>>>>> Thanks in advance,
>>>>>>
>>>>>> Tom
>>>>>
>>>>> Perhaps something as simple as the "ver" console command will meet
>>>>> your requirements.
>>>>
>>>> Perhaps a more succinct result can be had by extracting the "computer
>>>> role" value displayed by the "net accounts" command, i.e.:
>>>>
>>>> for /f "tokens=3" %F in ('net accounts ^| find /i "computer role:"') do
>>>> (set role=%F)
>>>>
>>>> /Al
>>>
>>> Nice ! but be careful : a DC is not a "SERVER"

>>
>> I'm not sure if you mean that a DC returns a value of "DC", not "SERVER",
>> or if you have non-server O/S systems performing the DC role. Like the
>> "VER" method, this gives you information that differentiates computers in
>> some way. If not in exactly the way one might expect, it still might
>> allow the desired information to be deduced.

>
>>
>> I have not tried this on computers having every possible combination of
>> roles. In our environment it is safe to assume that anything not
>> reporting itself as "WORKSTATION" would be some sort of server. Some
>> people have also assumed that if the first character in the computername
>> is "S", then it is a server, as that was part of our original naming
>> convention. Of course, code based on that assumption is broken now...
>>
>> Of course, it all boils down to what differentiates "servers" from
>> "clients" in the OP's environment.
>>

> I Think that the test of "Workstation" is a better way
> On my own server (French 2003 entreprise DC) the value is : "PRINCIPAL"
> (primary)


Hmmm, I hadn't even thought of the obvious globalization issues....

/Al


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Failure audits for object access on logon scripts and startup scripts, but clients still run them fine. Meinolf Weber Server Networking 0 02-27-2008 12:50 PM
Re: Failure audits for object access on logon scripts and startup scripts, but clients still run them fine. Meinolf Weber Windows Server 0 02-27-2008 12:50 PM
user scripts VS computer scripts Fernando Scripting 1 02-21-2005 06:16 PM
Sysvol scripts over GP logon scripts David Windows Small Business Server 1 04-26-2004 04:35 PM
How to call a DOS shell command from VB scripts? Aiker Peng Scripting 2 10-08-2003 03:18 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59