#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <Excel.au3>
#include <Array.au3>
#include <Excel.au3>
#include <Array.au3>
#include <Misc.au3>
MsgBox(64, "Tutorial", @UserName)
;MsgBox(64, "Tutorial", @ComputerName)
$sFilePath1 = "D:\NameList.xlsx" ;文件所在路径
$oExcel = _ExcelBookOpen($sFilePath1,0,true) ;打开这个EXCEL文件
MsgBox(0, "Test result","1")
Local $avArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
MsgBox(0, "Test result","2")
Local $iIndex = _ArraySearch($avArray, @UserName, 0, 0, 0, 1)
Local $sCellValue = _ExcelReadCell($oExcel, $iIndex, 2)
MsgBox(0, "Test result",$sCellValue)
MsgBox(0, "", "The Cell Value is: " & @CRLF & $sCellValue, 2)
Local $result = StringInStr($sCellValue, "C3")
MsgBox(0, "Search result:", $result)
If $result < 1 Then
_ExcelBookClose($oExcel,1)
Exit
EndIf
MsgBox(0, "Test result","OK")
RegWrite("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName","ComputerName","REG_SZ",$sCellValue)
RegWrite("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName","REG_SZ",$sCellValue)
RegWrite("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters","NV Hostname","REG_SZ",$sCellValue)
RegWrite("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters","Hostname","REG_SZ",$sCellValue)
Sleep(3000)
_ExcelBookClose($oExcel,1);
现在有个问题,修改注册表里计算机名字这个功能不能实现,经测试必须用管理员权限运行才能实现,用管理员权限运行这段代码的功能怎么实现?