aaalgo / hyperv2hosts

MIT License
24 stars 2 forks source link

Doesn't update hosts file #1

Open damthemad opened 1 year ago

damthemad commented 1 year ago

Hi,

Nice tool but unfortunately it doesn't works for me.

I see that the program is triggered as a new line apparead in the file the first time i started an hyperv vm, but this is only a comment, and after other trials (shutdown and restart vm) nothing happenend.

the line who appeared is below :

[HYPERV2HOSTS] Updated at Tue Jan 31 18:48:44 2023

Windows 10/64

br

aaalgo commented 1 year ago

It's indeed not working all the time. Two things to check:

PS, I just changed the hosts file format. The original order in line 99 was wrong.

damthemad commented 1 year ago

Hi,

The user which run the task is member of group admin

The powershell command returns nothing but this is normal as you pass an argument "-VMName linux" and my VM is not named "linux". if i change the argument with my vm name, the command is ok and returns VM's IP Address.

According to readme, i understand that this program should list all vms, so the name shouldn't be fixed. Do you mean that it is only functional for one unique vm whose name is linux ? It seems that's true since i can see this powershell command in source code (i can't compile ccp source code, no tools, and last time i did c++ was almost 20 years ago). Perhaps, coud you run "Get-VM | Get-VMNetworkAdapter | Select VMName, IPAddresses" and iterate on the results ?

br

aaalgo commented 1 year ago

I've added a new release here: https://github.com/aaalgo/hyperv2hosts/releases/tag/1.0.2

You need to supply the guest name with the command line argument "-n vmname" or "--name vmname". If you want to change the hostname, you can use "--host-fmt vm_{}", where {} will be replaced with guest name.

I'm not sure if this will work. I chose C++ so I can build something standalone, but maybe a python script will be better for the purpose.

damthemad commented 1 year ago

It doen't work. I'v added --name xxxx (xxx = vm name) and always nothing in my host file. since i now know how to detect starting event, thanks to Readme, i will write my own tool. br