2
1
I tried reg add
but it keeps saying invalid syntax
. Does anyone know how to edit the registry using .bat
files?
2
1
I tried reg add
but it keeps saying invalid syntax
. Does anyone know how to edit the registry using .bat
files?
5
reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber /t REG_DWORD /d <newportnumber>
A few things to note:
reg.exe
to treat Server\WinStations\RDP-Tcp
as another parameter, without the required parameter flag, which is likely what caused your error.REG_DWORD
as the type, otherwise, it will be overwritten as REG_SZ (string)
.reg.exe
tool seems to default to using hex, rather than decimal. I'm not sure whether, if you were to specify a port of 2000
, it would treat that as decimal 2000
or as 0x2000
(decimal 8192). It might only use hex if you prefix the number with 0x
, but you should experiment.sc stop <servicename> && sc start <servicename>
.shutdown /g
.
/g
means to reboot and come back to the current user and as potentially some of the current programs; use /r
instead for a simple reboot.shutdown
gives you 30 seconds before the machine shuts down / reboots, and also will not reboot if any program resists closing (perhaps because of unsaved files). You can use the /t <seconds>
parameter to tell it to restart after some other number of seconds, and you can use /f
to force it to restart even if programs don't want to exit. Using /t
with any number of seconds greater than 0 will imply /f
as well.
1Correct syntax can be found via
reg /?
orreg add /?
– JW0914 – 2019-12-08T13:39:22.657