Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Determining the computername of a computer through logon script using multiple if statements

Posted on 2006-07-12
2
Medium Priority
?
323 Views
Last Modified: 2012-06-27
Hi guys!

Hope you can help.

We have citrix users that are located in different states throughout Australia.
What I need to do is to determine the first 3 letters of their computer name when they logon to a citrix server, so as to run different parts of a batch file (logon script).

So, the batch will be something like:

IF %COMPUTERNAME%==MUL* goto
IF %COMPUTERNAME%==SIL* goto y
IF %COMPUTERNAME%==ASQ* goto z
else goto end:



:x


:y

:z

:end

Im pretty sure you cant use a wildcard statement with the IF statements.
Can anyone lead me in the right direction please (would really appreciate it).

Thanks guys.

Simon

0
Comment
Question by:Simon336697
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 17088538
Use this:
if /i "%ComputerName:~0,3%"=="MUL" goto x
if /i "%ComputerName:~0,3%"=="SIL" goto y
if /i "%ComputerName:~0,3%"=="ASQ" goto z
This will extract 3 characters from the position 0 in the %computername% variable.
Enter "help set" in a command line for a detailed explanation of this construction.
0
 
LVL 1

Author Comment

by:Simon336697
ID: 17088813
oBdA!

Youre a champion!

Thank you very much!!

Simon
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question