Jump to content

Recommended Posts

Posted

I am running this script to adjust the MTU on all remote users on the domain, since Watchguard SOHO 6 issues require fragment size changes.

The dcs are Win2003, and most end users have WinXP pro.

-----

$NetCard = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\2", "ServiceName")

RegWrite("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\$NetCard$", "MTU", "REG_DWORD", "1250")

-----

I want to run this for every interface available on their computer as many of the users have laptops and I need their wireless and onboard nic to have the MTU set to 1250.

Is there a simple way to change the (\NetworkCards\2", ) variable 2 to cover all subfolders in the \NetworkCards?

I noticed that many of the users have a range of 2 - 10 nics available and I am looking for a solution that will direct the RegRead to locate all the available NetworkCards and setup the MTU on the desired interfaces.

Any help is appreciated.

Posted (edited)

I am new to this Forum and have primarily used Peril in the past. I plan on using AutoIt more in the future for smaller simpler scripts as the one above. I have tried the basic folder variables as \* and \*.* but neither have worked.

Edited by schilbiz
  • Moderators
Posted

Not tested obviously:

_NetCardChange()
Func _NetCardChange($strNAME = "MTU", $strType = "REG_DWORD", $strVal = "1250")
    Local $strEnumKey, $nEnum, $sNetCard
    Local $strKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\" & _
            "Windows NT\CurrentVersion\NetworkCards"
    Local $strWriteKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" & _
            "Services\Tcpip\Parameters\Interfaces\"
    While 1
        $nEnum += 1
        $strEnumKey = RegEnumKey($strKey, $nEnum)
        If @error <> 0 Then ExitLoop
        $sNetCard = RegRead($strKey & "\" & $strEnumKey, "ServiceName")
        If $sNetCard Then RegWrite($strWriteKey & $sNetCard, $strNAME, $strType, $strVal)
    WEnd
    Return
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Not having used the While statement much, at first glance it looked like it would enter an infinity loop. But after looking at it more closely it looked like it should work fine. After testing it on a few different computers it is working great. Thanks a lot SmOke_N, one thing I did notice is that it does not work on Vista laptops. If you know what that change might be I would appreciate it. The paths are identical as far as

"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"

and

"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards" are concerned.

Thanks a lot for the quick reply and thought out solution, I plan on using AutoIt more and will attribute to the Forums once I am able.

  • Moderators
Posted

Try putting:

#RequireAdmin

At the top of your script.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

Brilliant, Thank you.

Now I will integrate it into my logon script and not have to manually configure 300 registrys.

Thanks for your time and saving me tons of time.

Posted

Now that I am requiring admin would this work to set the domain admin credentials when someone logs on and this file loads via the logon script?

RunAsSet("Administrator", "Domain", "Password", 0)

RunAsSet()

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
  • Recently Browsing   0 members

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