无名蜘蛛 发表于 2010-9-14 14:36:55

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,"修改成功!!!!")不可实现

lixiaolong 发表于 2010-9-14 14:42:10

回复 1# 无名蜘蛛

&$term 把"&"去掉即可

无名蜘蛛 发表于 2010-9-14 14:42:17

也许是有办法的,我今天才看的AU3也许还不是很了解,baidu google都找不到资料。。。

无名蜘蛛 发表于 2010-9-14 14:54:07

谢谢,真的可以了                        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,"修改成功!!!!")原来真的是一个符号的问题,汗。。。

tianji028 发表于 2010-9-15 22:29:49

编译的时候 不报错。。

无名蜘蛛 发表于 2010-9-17 08:44:56

本帖最后由 无名蜘蛛 于 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,"修改成功!!!!")

lixiaolong 发表于 2010-9-19 22:09:40

回复 6# 无名蜘蛛

Dim $term = 如果没有同名的变量可以去掉
Case $term>1024 And $term<=9999 = 可以精简,Case Else

netegg 发表于 2010-9-19 22:15:08

本帖最后由 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

afan 发表于 2010-9-19 22:59:27

$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]
查看完整版本: RegWrite 如何调用变量[已解决]