Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Looking for code that will compare hostname

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,65351
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Looking for code that will compare hostname
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Looking for code that will compare hostname - 10/21/2008 1:39:58 AM   
  cavalierboy

 

Posts: 2
Score: 0
Joined: 10/21/2008
Status: offline
Hi all,

i'm looking for a script that will compare hostname and map drive depending of the hostname.

This is what I already try and did not work.

Option Explicit
On Error Resume Next
Dim objShell
Dim regHostname
Dim  Hostname

regHostname = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname"

Set objShell = CreateObject("WScript.Shell")
ActiveComputerName = objShell.RegRead(regActiveComputerName)
ComputerName = objShell.RegRead(regComputerName)
Hostname = objShell.RegRead(regHostname)

If Hostname = "2k3invpro01" Then
objShell.NameSpace("u:").Self.Name = UCase(UserName) & " Home Drive"
WScript.Quit
ElseIf Hostname = "2k3cit02" Then
objShell.NameSpace("u:").Self.Name = UCase(UserName) & " Home Drive"
WScript.Quit
ElseIf Hostname = "2k3cit03" Then
objShell.NameSpace("u:").Self.Name = UCase(UserName) & " Home Drive"
WScript.Quit
End If


Thanks for the help


_____________________________

cavalierboy
 
 
Post #: 1
 
 RE: Looking for code that will compare hostname - 10/21/2008 3:43:52 AM   
  cavalierboy

 

Posts: 2
Score: 0
Joined: 10/21/2008
Status: offline
i'm most likely looking for a script that will check what's the computer name and exit if the computer name is 2k3cit02.

Thanks

_____________________________

cavalierboy

(in reply to cavalierboy)
 
 
Post #: 2
 
 RE: Looking for code that will compare hostname - 10/21/2008 3:47:47 AM   
  ehvbs

 

Posts: 2224
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi cavalierboy,

(1) remove the evil "On Error Resume Next"

(2) make sure that all variables you use are initialized properly
    (e.g. regActiveComputerName, ... )

(3) Try again

Good luck!

ehvbs

(in reply to cavalierboy)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Looking for code that will compare hostname Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts