Arduino Mega code uploading using AVRDUDE

I want to upload code to arduino by simply running .exe file. So im trying with command line first I am uploading code to arduino using command but I need to select port number by using instruction -PCOM23. I have tried command -PavrispmkII to but not successful .

Please suggest.

Please provide a more detailed description of what you're trying to accomplish.

knowledge:
I have tried command -PavrispmkII to but not successful

Do you have an AVRISP mkII ISP programmer connected to your Arduino board?

Hey, I am using USB cable to program arduino. using following command line:

"" "-C<avrdude.conf path>" -q -q -patmega2560 -cwiring -PCOM44 -b115200 -D -Uflash:w:C:\Users\code.ino.hex:i

But is there a way that I don't have to select port number.

If there is update to current version in firmware customer should be able to upload the code with minimum efforts that's the goal.

If you want to upload over the USB cable of the Arduino Mega then you need to specify the serial port. If you are using a pure USB ISP programmer like the AVRISP mkII or USBASP connected to the ICSP header on the Mega then you don't need to specify the serial port.

Maybe you can find some way to automatically determine the correct serial port using the VID/PID of the Mega. I don't know how that would be done. It definitely would take some separate program from avrdude.

Serial port above 9 must be specified on windows: -P\.\COM44 and it works also for port numbers less than 10.
As @pert wrote, for the programmers like USBasp you need not port number, just programmer type like: -cUSBasp.