Jump to content

regwrite new computername


Recommended Posts

Can someone please help me? i am writing a script for a college that will rename all the machines to the username that they type in. The only problem I am having right now is that when I do a regwrite to change the computer name it does not write the name typed in the input box, it types an 11 instead. I am VERY new so if you could post the correct regwrite code that will take a variable and enter it in where the computer name goes that would be great! below is the code I have so far. I know i need some serious help!

$contextMenu = GuiCtrlCreateContextMenu()

GuiCtrlCreateMenuItem("Context Menu", $contextMenu)

GuiCtrlCreateMenuItem("", $contextMenu) ;separator

GuiCtrlCreateLabel("Enter Network Username", 9, 4, 153, 15)

$username = GuiCtrlCreateInput("", 135, 4, 153, 15)

$Submit = GUICtrlCreateButton ("Submit", 10, 330, 100, 30)

GUISetState () ; will display an dialog box with 2 button

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $Submit

RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", $username)

RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", $username)

Link to comment
Share on other sites

You need to use GUICtrlRead.

RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", GUICtrlRead($username))
RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", GUICtrlRead($username))

Edit: Welcome to AutoIt....

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

You need to use GUICtrlRead.

RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "Hostname", "REG_SZ", GUICtrlRead($username))
RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "NV Hostname", "REG_SZ", GUICtrlRead($username))

Edit: Welcome to AutoIt....

:shocked: Thank you so much!!! I was killing myself over this! All you guy's that help us nube's are awsome! Thanks again!

Jay

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...