I would like to read the hostname of my device and generate a file with such name. However, I am new in Windows Batch, I don't even understand how to use of those variable, read file......
Here is what I want to do:
CD C:\WINDOWS\SYSTEM32\
CMD.EXE hostname -> to a HostName variable e.g. called abc ::I hope it will save my computer name to a variable string
echo It success to function >> C:\%abc%.txt :: I hope it can generate a file with the sting in variable
PAUSE
I have thought that if it is not function with cmd command, so I tried the alternative method:
CD C:\WINDOWS\SYSTEM32\
CMD.EXE hostname >> C:\HostName.tmp
-AND THEN READ BACK the C:\HostName.tmp Here
-And then save to a variable again e.g.
echo It success to function >> C:\HostName_variable.txt ::It generate a file with the sting in variable
PAUSE
It seems not successful =[.
Added: I would like to create a file with the name of hostname. e.g. if my hostname is "abc", it will output a file as "abc.csv" something like this.
echo %computername%>newfile.txt. Typesetto see a list of variables.echo %computername%>%computername%.csv. One line, that's all.