OK
But how can I know the AmsId of AdvancedHMI?
This may be a little tricky. The logic is:
1) Check registry for HKEY_LOCAL_MACHINE\Software\Beckhoff\TwinCAT\System\AmsNetId
2) If not in registry, get list of IPv4 addresses on PC. Use first IP address where first byte matches that of TwinCAT target IP
3) If unable to get an IPv4 address, then take last 3 bytes of MacID and ccreate 99.b3.b4.b5.1.1
So the best way to definitely know is to use RegEdit to create the key and value. If you open RegEdit on a machine with TwinCAT installed, you will see the same key created when TwinCAT was installed.