Hello,
I have following script that is running as startup task:
@echo off
setlocal
set regpath=HKLM\System\CurrentControlSet\Services\HTTP\Parameters
set regvalue=UrlSegmentMaxLength
set message=VM rebooted because registry was modified due to long ID issue
reg query "%regpath%" /v "%regvalue%" /t "REG_DWORD"
if errorlevel 1 (
reg add "%regpath%" /v "%regvalue%" /t "REG_DWORD" /d 0x1000 /f
shutdown /r /t 1 /d p:4:1 /c "%message%"
exit /b 0
)
After reboot of VM using 'shutdown' command remote access for this instance become unavailable. Of cause, if I do not run 'shutdown' in startup task then RDP works well.
To restore RDP access I need to do manual reboot via Azure Management Portal.
In event log I can see error event that says: "The RdAgent service hung on starting."
And I suspect that it's a possible reason of why RDP become broken. But I was not able to find any help about it.
I tried to use 'shutdown' command with various timeout values, that are 1, 60, 120 seconds but result always was the same.
I even tried to run startup task as 'background' task - RDP still was broken.
Could you advise anything?