Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blocking Login Script on Servers

Status
Not open for further replies.

jwithi

Technical User
Jan 13, 2008
32
GB
Afternoon Everyone,

I am trying to configure things so that when me and my team logon to servers it does not run our normal domain login script, but does run the login script when we logon to a workstation.

i know this can be done through the login script by setting it up so that if it detects a file in a certain location it exits the script.

I wonder if this is something that could also be done using group policy, as all our servers are in 1 OU, except for the DC's. I know setting the login script in group policy is a user configuration though....?

Any ideas...........?
 
Don't know about using group policy, but here we just determine the OS to decide if it is a server or not and the Login script acts appropriately from there.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Any advice on how i can amend my current VBscript to exit if it detects the OS as being a server OS?
 
see if this helps:

Function ServerCheck()
Dim objWMIService
Dim colItems
Dim objItem
Dim strComputer: strComputer = "."

ServerCheck = False
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem In colItems
If InStr(1,objItem.Caption,"Server") Then
ServerCheck = True
End If
Next
Set objWMIService = Nothing
Set colItems = Nothing
Set objItem = Nothing
End Function

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks for that, any idea of where i would place this in my script?

I am a bit of a novice when it come to vbscript, this is the first one i have ever attempted to put together.

Any other ways of doing this would also be greatly appreciated.

Regards,

jwithi
 
At the top of your script if you remove the Function
or place the Function at the end where it supposed to go and call it from the top e.g. Call ServerCheck
You can also do this

Code:
'Do not run on these machines (list of servers)
Set objNetwork = CreateObject("WScript.Network")
	thisComputer = objNetwork.ComputerName
	arrComputers = Array("Computer","Server","Server","Computer")
For Each arrayElement in arrComputers
	if arrayElement = thisComputer then
		wscript.Quit
	end if 
next
 
Does this mean i would have to list every server we have that i do not want the script to apply to?

All our servers are either 2000 or 2003 server so would prefer to have something that says if 2000/2003 server quit, else next sor of thing. is that possible.
 
mmmm
Any other ways of doing this would also be greatly appreciated.
That would be what I posted, and Yes each computer name.

All our servers are either 2000 or 2003 server so would prefer to have something that says if 2000/2003 server quit, else next sor of thing
I sure thats what ebgreen posted.

You may just want to cahnge it a bit to read

If InStr(1,objItem.Caption,"Server") Then Wscript.Quit
If InStr(1,objItem.Caption, "Server 2003") Then Wscript.Quit
 
Thanks for the help and advice guys, it is much appreciated. i have a few of my team testing this and it appears to be doing the trick!

Thanks again!

Regards,
Jwithi
 
Morning Everyone,

A quick query really that may or may not be linked to the VB login script.

I have pushed a new VBScript out to just the IT department fors testing, and a few users have noticed that since they have been using the new script their home drives are not mapping to their folder, instead they are mapping to the 'users' folder.

This is quite strange because all home drives are mapped using the user AD account and are all configured to map to \\<servername>\<share>\%username%

I did a lot of testing with this new script and never had any problems.

Is it possible that the new VBScript is somehow messing with the home folder mappings?
 
faq329-5798

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top