当前位置: > 部署 >

NSIS:把计算机名转换为大写或小写字符

  • 部署
  • 2014-08-29 22:14

最近在做一个包的时候,轻狂遇到了转换大小写的问题,网络上似乎没有相关例子可以借鉴,研究了一下发现用WordFunc.nsh头文件可以实现,于是记一下方便大家。

 

	;从注册表中读取当前计算机名
	ReadRegStr $R1 HKLM "SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName"
	MessageBox MB_OK "计算机名$R1"
	;把字符串转换为大写,如果转换为小写则把+改为-即可,还可以设置某些字符不转换哦
	${StrFilter} "$R1" "+" "" "" $R2
	MessageBox MB_OK "转换后的计算机名$R2"
	;把计算机名全部改为大写
	WriteRegStr   HKLM "SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName" "$R2"
	WriteRegStr   HKLM "SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName" "$R2"
	WriteRegStr   HKLM "SYSTEM\CurrentControlSet\services\Tcpip\Parameters" "NV Hostname" "$R2"
	WriteRegStr   HKLM "SYSTEM\CurrentControlSet\services\Tcpip\Parameters" "Hostname" "$R2"
	WriteRegStr   HKLM "SYSTEM\ControlSet001\Control\ComputerName\ComputerName" "ComputerName" "$R2"
	WriteRegStr   HKLM "SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName" "ComputerName" "$R2"
	WriteRegStr   HKLM "SYSTEM\ControlSet001\services\Tcpip\Parameters" "NV Hostname" "$R2"
	WriteRegStr   HKLM "SYSTEM\ControlSet001\services\Tcpip\Parameters" "Hostname" "$R2"
	WriteRegStr   HKLM "SYSTEM\ControlSet002\Control\ComputerName\ComputerName" "ComputerName" "$R2"
	WriteRegStr   HKLM "SYSTEM\ControlSet002\services\Tcpip\Parameters" "NV Hostname" "$R2"
	WriteRegStr   HKLM "SYSTEM\ControlSet002\services\Tcpip\Parameters" "Hostname" "$R2"
	WriteRegStr   HKCU "Software\Microsoft\Windows Media\WMSDK\General" "ComputerName" "$R2"
	WriteRegStr   HKCU "Volatile Environment" "LOGONSERVER" "\\$R2"
	WriteRegStr   HKCU "Volatile Environment" "USERDOMAIN" "$R2"

 

猜你喜欢

最新评论

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!