Basic CMD command needs explanation
-
@echo off
copy \server\netlogon\hosts "%systemroot%\system32\drivers\etc\hosts /y
rem type \server\netlogon\hosts >> %systemroot%\system32\drivers\etc\hostsWe use the same domain as our website. When we access out website without www infront it redirect to IIS instead of filling in www.domain.com. Now... we found the above command batch that will solve our issue.
The instruction is to create a file (no extension) and named it hosts. Inside input our website IP address and redirective keyword. Somehow it works! our domain.com become www.domain.com. However I don't understand how it works since hosts file was not altered.
Also what does rem type do? I tried rem type /? in cmd but nothing happens. REM supposed to be a remark command for batch file... but why? How? What? o_O feel so noobish asking this question. LOL *cry in corner *
-
The 2nd line has been REM'd or remarked out. It does nothing.
-
First line is copying the hosts file from the server to the local system directory.
Have you checked the contents of the host file @ \server\netlogon?
-
@LAH3385 said in Basic CMD command needs explanation:
@echo off
copy \server\netlogon\hosts "%systemroot%\system32\drivers\etc\hosts /y
rem type \server\netlogon\hosts >> %systemroot%\system32\drivers\etc\hostsWe use the same domain as our website. When we access out website without www infront it redirect to IIS instead of filling in www.domain.com. Now... we found the above command batch that will solve our issue.
The instruction is to create a file (no extension) and named it hosts. Inside input our website IP address and redirective keyword. Somehow it works! our domain.com become www.domain.com. However I don't understand how it works since hosts file was not altered.
Also what does rem type do? I tried rem type /? in cmd but nothing happens. REM supposed to be a remark command for batch file... but why? How? What? o_O feel so noobish asking this question. LOL *cry in corner *
It looks like you are copying an already created host file. As @Danp said the second line is just for remarks.