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!

Script based on computer name

Status
Not open for further replies.

teddysherri

Technical User
Nov 18, 2003
137
GB
Hi Guys,

Bit new to scripting so go easy :)

We have just taken over another company and in the process of changing their IT. So far we have migrated them from their old NT4 domain to AD but have come a bit stuck with one of their servers.

They use a 3rd party application which sits on a TS owned by another company which we will call TS10. However they must 1st TS onto another server called ts30 and click on the shortcut to the application which sits on ts10 (all very confusing). The only problem being is that he users require a mapped drive to ts10 so it can pick up the license key, unfortunately the users do not have rights to map a drive or do anything for that matter on TS30.

Therefore is it possible to have a script, which will map this drive only when the users logon to ts30 and not when they logon to their local machine?

Thank you for your help.
 
Create yourself an AD group, put the terminal server users into it. Use the IsMember function with If, Then to map a drive if they are a member.

The only way I can see would be to put the script in the StartUp folder on the TS3 - you can use DOS to fire the script silently...

;-)
 
Off the top of my head...(with a bit of cut and pasting, i.e., I've not tested this)
Code:
Set WshNetwork = WScript.CreateObject("WScript.Network")
if UCase(WshNetwork.ComputerName) = "TS30" then
    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.MapNetworkDrive "T:", "\\TS30\LicenseKeyShare"
    Set objNetwork = Nothing
end if
Set WshNetwork = Nothing

Obviously you'll have to fill in the correct sharename (in place of "LicenseKeyShare") and choose a different drive letter if T: is no good, but otherwise I think this code snippet will do what you need.

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
WshNetwork and then objNetwork, why is that?

And then, if there is no issue of "remote" access and/or event callback, why one use wscript.createobject and the other straight createobject? What is their difference do you think in all practicality?

You may think I'm picky. But since you show a laudable will to help, maybe you should sharpen up the skill a bit? This note is for your own good.
 
>WshNetwork and then objNetwork, why is that?

No good reason whatsoever!

Good spot, like I said though, I was working quickly and cutting and pasting. So, corrected code snippet:
Code:
Set objNetwork = CreateObject("WScript.Network")
if UCase(objNetwork.ComputerName) = "TS30" then
    objNetwork.MapNetworkDrive "T:", "\\TS30\LicenseKeyShare"    
end if
Set objNetwork = Nothing

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top