Link to home
Start Free TrialLog in
Avatar of chrisryhal
chrisryhal

asked on

Script to check computer name

I need a quick VBScript that basically looks for a computer name.  When the VBScript is ran if the computer name is "k-tsvr2" then DO NOTHING if it is anything BUT k-tsvr2 then launch a batch file.
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Why do you need a vbscript... why not just use the batch file?

If "%computername%" == "k-tsvr2" GOTO End
REM --- DO EVERYTHING HERE
REM --- ETC
REM --- ETC
:End
Avatar of chrisryhal
chrisryhal

ASKER

Because I have a HUGE VBScript and want the code in there.  
One way...

Dim objNet:Set objNet=CreateObject("Wscript.Network")
If objNet.ComputerName="k-tsvr2" Then Wscript.quit
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial