Jump to content

Send data to sql database


Recommended Posts

The following script which I collected from several sources on this forum, retrieves the Mac address from the wireless card, and also creates a 17 character password. I'm doing this so I can configure the Peap authentication on my Radious server with those values.

I would like to send this values to a SQl server but don't know how?

Can someone please show me how to connect to the SQL server and update the table?

Thanks in advance.

#include <GuiConstants.au3>

Global $random[1000000],$pass
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"


GuiCreate("DIIT Wireless Config", 358, 109,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("", 100, 10, 170, 20)
$Button_2 = GuiCtrlCreateButton("Copy", 290, 10, 60, 20)
$Button_3 = GuiCtrlCreateButton("Copy", 290, 40, 60, 20)
$Input_4 = GuiCtrlCreateInput("", 100, 40, 170, 20)
$Label_5 = GuiCtrlCreateLabel("Mac Address", 10, 10, 70, 20)
$Label_6 = GuiCtrlCreateLabel("Password", 10, 40, 60, 20)
$Button_7 = GuiCtrlCreateButton("Exit", 140, 80, 60, 20)


passcreate()
GetMac()

GuiSetState()



do
    $msg = GuiGetMsg()
    
    if $msg = $Button_2 then ClipPut(GUICtrlRead($Input_1))
    if $msg = $Button_3 then ClipPut(GUICtrlRead($Input_4))
    if $msg = $Button_7 Then exit
        
until $msg = $GUI_EVENT_CLOSE



func passcreate()
    GUICtrlSetData($Input_4,"")
    for $b = 1 to 17
        $random[$b] = ""
    Next 
    for $iCC = 1 to 17
        if Random(1,3,1) = 1 Then 
            $random[$iCC] = random(48,57,1)
            $pass = GUICtrlRead($Input_4) & chr($random[$iCC])
            GUICtrlSetData($Input_4,$pass)
        Elseif Random(1,3,1) = 2 then
            $random[$iCC] = random(65,90,1)
            $pass = GUICtrlRead($Input_4) & chr($random[$iCC])
            GUICtrlSetData($Input_4,$pass)
        Else
            $random[$iCC]= random(97,122,1)
            $pass = GUICtrlRead($Input_4) & chr($random[$iCC])
            GUICtrlSetData($Input_4,$pass)
        EndIf
    Next
EndFunc


func GetMac()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      
      $Output = $Output & StringReplace($objItem.MACAddress, ':', '') 
      GUICtrlSetData($Input_1,$Output)
     ;if Msgbox(0,"WMI Output",$Output) = 1 then ExitLoop
      if $Output = 1 then ExitLoop
     ;  ConsoleWrite($Output)
     ;  ConsoleWrite(@CR&@CR)
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration" )
Endif
EndFunc
Link to comment
Share on other sites

Thanks,

I followed all the links, and did resarch on the forum, but still can not get a clear answer to my question?

Can someone please just show me how to connect, and add those 2 items to the database?

Thanks you.

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...