RegWrite 如何调用变量[已解决]
本帖最后由 无名蜘蛛 于 2010-9-20 09:34 编辑如题Dim $term
$termo = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber")
$term = InputBox("修改","请输入新端口,当前使用端口"&$termo)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber", "REG_DWORD",&$term)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp", "PortNumber", "REG_DWORD",&$term)
MsgBox(0,"新的端口"&$term,"修改成功!!!!")不可实现 回复 1# 无名蜘蛛
&$term 把"&"去掉即可 也许是有办法的,我今天才看的AU3也许还不是很了解,baidu google都找不到资料。。。 谢谢,真的可以了 Dim $term
$termo = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber")
$term = InputBox("修改","请输入新端口,当前使用端口"&$termo)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber", "REG_DWORD",$term)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp", "PortNumber", "REG_DWORD",$term)
MsgBox(0,"新的端口"&$term,"修改成功!!!!")原来真的是一个符号的问题,汗。。。 编译的时候 不报错。。 本帖最后由 无名蜘蛛 于 2010-9-17 08:46 编辑
呵呵,当然会错完整的如下,修改3389远程桌面的端口
不知还可以优化下不?
Dim $term
$termo = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber")$term = InputBox("修改","请输入新端口,当前使用端口"&$termo,"3389")
Select
Case $term = ""
MsgBox(0,"修改","取消操作")
Case $term<=1024 Or $term>9999
MsgBox(0,"修改","不能小于1024或者大于9999")
Case $term>1024 And $term<=9999
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber", "REG_DWORD",$term)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp", "PortNumber", "REG_DWORD",$term)
MsgBox(0,"新的端口"&$term,"修改成功!!!!")
回复 6# 无名蜘蛛
Dim $term = 如果没有同名的变量可以去掉
Case $term>1024 And $term<=9999 = 可以精简,Case Else 本帖最后由 netegg 于 2010-9-19 22:22 编辑
select
Case $term>1024 And $term<=9999
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber", "REG_DWORD",$term)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp", "PortNumber", "REG_DWORD",$term)
Case else
if $term = "" then
MsgBox(0,"修改","取消操作")
else
MsgBox(0,"修改","不能小于1024或者大于9999")
endif
endselect $termo = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber")
$term = InputBox("修改", "请输入新端口,当前使用端口" & $termo, "3389")
Switch $term
Case ''
MsgBox(0, "修改", "取消操作")
Case 1024 To 9999
;~ RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp", "PortNumber", "REG_DWORD", $term)
;~ RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp", "PortNumber", "REG_DWORD", $term)
MsgBox(64, "新的端口" & $term, "修改成功!!!!")
Case Else
MsgBox(48, "修改", "不能小于1024或者大于9999")
EndSwitch
页:
[1]