get FQDN
-
2012年5月7日 6:52
I want to get FQDN in lower case of my machine using command line which I want to use in my batch script.
i am trying this:
set fqdn = %COMPUTERNAME%.%USERDNANAME%
However this gives the info in uppercase letter.
Is there any way to get this info in lowercase.?
すべての返信
-
2012年5月7日 7:36
Yes there is, not an easy way but here is an example of how you can do this in batch:
@ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET FQDN=%COMPUTERNAME%.%USERDNSDOMAIN% CALL :LoCase FQDN ECHO %FQDN% ENDLOCAL GOTO:EOF :LoCase :: Subroutine to convert a variable VALUE to all lower case. :: The argument for this subroutine is the variable NAME. SET %~1=!%1:A=a! SET %~1=!%1:B=b! SET %~1=!%1:C=c! SET %~1=!%1:D=d! SET %~1=!%1:E=e! SET %~1=!%1:F=f! SET %~1=!%1:G=g! SET %~1=!%1:H=h! SET %~1=!%1:I=i! SET %~1=!%1:J=j! SET %~1=!%1:K=k! SET %~1=!%1:L=l! SET %~1=!%1:M=m! SET %~1=!%1:N=n! SET %~1=!%1:O=o! SET %~1=!%1:P=p! SET %~1=!%1:Q=q! SET %~1=!%1:R=r! SET %~1=!%1:S=s! SET %~1=!%1:T=t! SET %~1=!%1:U=u! SET %~1=!%1:V=v! SET %~1=!%1:W=w! SET %~1=!%1:X=x! SET %~1=!%1:Y=y! SET %~1=!%1:Z=z! GOTO:EOF
For more examples of how to do this in batch have a look at this website: http://www.robvanderwoude.com/battech_convertcase.php
It is a great resource with hundreds of examples of batch scripting.
- 回答としてマーク ankurgoel84 2012年5月7日 8:57
-
2012年5月7日 14:20モデレータ
Hi,
An alternative, if you're stuck with only shell scripting and can use external executables, would be to use the ccase utility I wrote a while back:
for /f "delims=" %%v in ('echo %FQDN% ^| ccase -l') do set FQDN=%%vBill

