having problem with the port for uno and nano

Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno"

avrdude: ser_open(): can't open device "\.\COM4": Access is denied.

Error while burning bootloader.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

any suggestions please help

Is the port in the IDE indeed COM4 (or did it change to e.g. COM5; tools->port).

Any anti-virus interfering; temporarily disable it to check.

Was this always a problem or did it suddenly happen?

For burning the bootloader, please follow the instructions as shown on the Arduino as ISP page. https://www.arduino.cc/en/tutorial/arduinoISP