#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=logogreenASDFG.ico #AutoIt3Wrapper_Res_Fileversion=1.0.0.24 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;http://agent.ASDFG.com.au/dl.asp?id=-1 ;http://agent.ASDFG.com.au/mkdefault.asp?id=-1 ;Opt('MustDeclareVars', 1) #Include #include #Include #include #include #include #include #include #include #Include #include Global $isAdminVersion = 0 ; ####################### Multi / dual screen capture support Global $tag_DISPLAY_DEVICE = "dword cb;char DeviceName[32];char DeviceString[128];dword StateFlags;char DeviceID[128];char DeviceKey[128]" ;Global Const $DISPLAY_DEVICE_MIRRORING_DRIVER = 0x00000008 ;Global Const $DISPLAY_DEVICE_PRIMARY_DEVICE = 0x00000004 Global $tag_POINTL = "long x;long y" Global $tag_DEVMOD = "char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _ "ushort dmDriverExtra;dword dmFields;" & $tag_POINTL & ";dword dmDisplayOrientation;dword dmDisplayFixedOutput;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "byte dmFormName[32];ushort LogPixels;dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _ "dword dmDisplayFlags;dword dmDisplayFrequency" ;Global Const $ENUM_CURRENT_SETTINGS = -1 Global $AfterHour = "No" Global $Left, $Top, $Right, $Bottom Global $i = 0 While 1 $struct = DllStructCreate($tag_DISPLAY_DEVICE) DllStructSetData($struct, "cb", DllStructGetSize($struct)) $aRetrun = DllCall("user32.dll", "int", "EnumDisplayDevices", "ptr", 0, "dword", $i, "ptr", DllStructGetPtr($struct), "dword", 0) If Not $aRetrun[0] Then ExitLoop If Not BitAND(DllStructGetData($struct, "StateFlags"), $DISPLAY_DEVICE_MIRRORING_DRIVER) Then ; Avoid Virtual Displays ;~ ConsoleWrite(DllStructGetData($struct, "DeviceName") & @TAB & "Primary: " & (BitAND(DllStructGetData($struct, "StateFlags"), $DISPLAY_DEVICE_PRIMARY_DEVICE) > 0) & @CRLF) $dev = DllStructCreate($tag_DEVMOD) DllStructSetData($dev, "dmSize", DllStructGetSize($dev)) $aRetrun = DllCall("user32.dll", "int", "EnumDisplaySettings", "str", DllStructGetData($struct, "DeviceName"), "dword", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($dev)) If Not IsNumber($Left) Or $Left > DllStructGetData($dev, "x") Then $Left = DllStructGetData($dev, "x") If Not IsNumber($Top) Or $Top > DllStructGetData($dev, "y") Then $Top = DllStructGetData($dev, "y") If Not IsNumber($Right) Or $Right < DllStructGetData($dev, "x") + DllStructGetData($dev, "dmPelsWidth") Then $Right = DllStructGetData($dev, "x") + DllStructGetData($dev, "dmPelsWidth") If Not IsNumber($Bottom) Or $Bottom < DllStructGetData($dev, "y") + DllStructGetData($dev, "dmPelsHeight") Then $Bottom = DllStructGetData($dev, "y") + DllStructGetData($dev, "dmPelsHeight") EndIf $i += 1 WEnd ; ####################### END Multi / dual screen capture support ;Opt("GUIResizeMode",$GUI_DOCKALL) #Region ### START Koda GUI section ### Form=C:\Documents and Settings\RRDev\Desktop\koda_2008-10-03\Forms\ASDFGP.kxf if $isAdminVersion=1 Then $Form1_1 = GUICreate("!!!!! ASDFG ADMIN Helpdesk !!!!!", 463, 460, 192, 114) Else $Form1_1 = GUICreate("ASDFG Helpdesk", 463, 530, 192, 114) EndIf if $isAdminVersion=1 then GUICtrlSetBkColor(-1,0xffff99) EndIf GUICtrlSetData(-1, "") $cmdAttach = GUICtrlCreateButton("Attach File", 224, 360, 73, 25) $cmdScreenShot = GUICtrlCreateButton("ScreenShot", 304, 360, 81, 25) $cmdSubmit = GUICtrlCreateButton("Submit", 392, 360, 65, 25) $txtInfo = GUICtrlCreateEdit("", 8, 390, 449, 129) GUICtrlSetData(-1, "") if $isAdminVersion=1 then GUICtrlSetBkColor(-1,0xffff99) EndIf ;---------------------------------------------------------------------------------; $lblConnected = GUICtrlCreateLabel("Checking if Online", 8, 8, 452, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") ;---------------------------------------------------------------------------------; $Label1 = GUICtrlCreateLabel("Phone", 6, 54, 40, 17) $Label2 = GUICtrlCreateLabel("Email Address", 6, 78, 70, 17) $Label3 = GUICtrlCreateLabel("Full Name", 6, 102, 70, 17) $Label4 = GUICtrlCreateLabel("Subject", 6, 126, 40, 17) $Label5 = GUICtrlCreateLabel("Category", 6, 173, 50, 17) $Label6 = GUICtrlCreateLabel("Problem details/Instructions", 6, 210, 140, 17) ;---------------------------------------------------------------------------------; Func dLine1() GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1_1) ;$hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsDrawLine($hGraphic, 0, 156, 463, 156) EndFunc $txtPhone = GUICtrlCreateInput("", 90, 51, 161, 21) $txtEmailAddress = GUICtrlCreateInput("", 90, 75, 281, 21) $txtFullName = GUICtrlCreateInput("", 90, 99, 281, 21) $txtSubject = GUICtrlCreateInput("", 90, 123, 281, 21) dLine1() $radio1 = GUICtrlCreateRadio("Wisecloud", 90, 160, 185, 25) ;GUICtrlSetState(-1, $GUI_CHECKED) $radio2 = GUICtrlCreateRadio("Internet Speed Etc", 90, 180, 185, 25) ;GUISetState() $txtDetails = GUICtrlCreateEdit("", 8, 230, 449, 125) Global $chkPatrol, $Wise= 'Wisecloud', $Internet ='Internet Speed Etc' ;Select ; Case GuiCtrlRead($check1) = $GUI_CHECKED ; GUICtrlSetState($check2, $GUI_DISABLE) ; Case GuiCtrlRead($check2) = $GUI_CHECKED ; GUICtrlSetState($check1, $GUI_DISABLE) ;EndSelect Select Case GUICtrlRead($radio1) = 1 $chkPatrol = $Wise Case GUICtrlRead($radio2) = 1 $chkPatrol = $Internet EndSelect ;Func _IsChecked($check2) ; Return BitAnd(GUICtrlRead($check2),$GUI_CHECKED) = $GUI_CHECKED ;EndFunc ;While 1 ; Select ; Case $radiox = $GUI_EVENT_CLOSE ; ExitLoop ; Case $radiox = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED ; Return $radio1 ; Case $radiox = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED ; Return $radio2 ; EndSelect ;WEnd #EndRegion ### END Koda GUI section ### Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; This is my custom error handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc #include ; Used to determine if kaseya is installed dim $gScreenShotFile $gScreenShotFile="" dim $gAttachFile $gAttachFile="" ; Get/Generate a new Unique ASDFGID dim $ASDFGID $ASDFGID = GetASDFGID() dim $AppDataPath $AppDataPath = @AppDataDir & "\ASDFGSupport\" dim $gKIniFile $gKIniFile=GetKaseyaDIni() ;GUIResizeMode _Main() func _Main() ;MsgBox(0,"ASDFG Support",@AppDataDir) GUICtrlSetData($txtEmailAddress,IniRead($AppDataPath & "ASDFGSupport.ini","settings","email","")) GUICtrlSetData($txtPhone,IniRead($AppDataPath & "ASDFGSupport.ini","settings","phone","")) GUICtrlSetData($txtFullName,IniRead($AppDataPath & "ASDFGSupport.ini","settings","fullname","")) If HasInternetConnection() Then GUICtrlSetData($lblConnected,"Online") GUICtrlSetBkColor($lblConnected,0x00ff00) ;Green Else GUICtrlSetData($lblConnected,"Offline") GUICtrlSetBkColor($lblConnected,0xff0000) ; Red ; msgbox not connected. shrink form so no other buttons are visible. ! MsgBox(0,"Internet not connected","No internet connection ASDFG support not availbale") exit EndIf ;MsgBox(0,"a",$KaseyaUserName) if KaseyaInstalled() Then StartForm() Else ;MsgBox(0,"Kaseya is not installed", "Kaseya is not installed, will begin to download Kaseya Agent in Background, please wait a moment, this may take time depends on your connection") MsgBox(0,"Kaseya is not installed", "Kaseya is not installed, please install Kaseya agent first in order to use ASDFG Desktop Button") Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe https://ASDFG2.squarespace.com/kaseya-agent") ; Save the downloaded file to the temporary folder. ; $downloadsURL = ("http://agent.ASDFG.com.au/install/VSA-default--1/KcsSetup.exe") ;If InetGet($downloadsURL, @TempDir & '\KcsSetup.exe') Then ; ShellExecute(@TempDir & '\KcsSetup.exe') ;Else ; Msgbox(0,'ERROR','Error downloading file.') ;EndIf EndIf EndFunc func StartForm() GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo()) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select case $nMsg = $txtEmailAddress GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo()) case $nMsg = $txtPhone GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo()) case $nMsg = $txtFullName GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo()) Case $nMsg = $cmdScreenShot $gScreenShotFile = SaveScreenShot() case $nMsg = $cmdSubmit if ValidateForm() then if ASDFGSubmit() Then UpdateStatus("Your request has been sent successfully") MsgBox(0,"Help Requested","Your request has been sent successfully") ExitLoop Else MsgBox(0,"Help Failed","Something is wrong you request was not sent, please try again") Endif endIf case $nMsg = $cmdAttach $gAttachFile = AttachFile() Case $nMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd EndFunc Func URIEncode($sData) ;Return $sData ; Prog@ndy Local $aData = StringSplit(BinaryToString(StringToBinary($sData,4),1),"") Local $nChar $sData="" For $i = 1 To $aData[0] ;ConsoleWrite($aData[$i] & @CRLF) $nChar = Asc($aData[$i]) Switch $nChar Case 45, 46, 48-57, 65 To 90, 95, 97 To 122, 126 $sData &= $aData[$i] Case 32 $sData &= "+" Case Else $sData &= "%" & Hex($nChar,2) EndSwitch Next Return $sData EndFunc func ASDFGGetJobID() dim $tic $tic = _TimeToTicks() ; to esure the page is not cache we add unquie tc count as a query string dim $eventDes dim $rmarks $eventDes = GUICtrlRead($txtSubject) $rmarks = GUICtrlRead($txtDetails) dim $URL $URL = "http://www.ASDFG.com.au/ASDFGSupport/EventsSubmit.asp" $URL &= "?eventDes=" & $eventDes $URL &= "&rmarks=" & $rmarks $URL &= "&tick=" & $tic Dim $JOBData ;$JOBData = InetRead($URL) $JOBData = HTTPRequest($URL,"GET","") dim $JOBID $JOBID = BinaryToString($JOBData) return $JOBID EndFunc func SaveSettings() IniWrite(@AppDataDir & "\ASDFGSupport\ASDFGSupport.ini","Settings","Email",GUICtrlRead($txtEmailAddress)) IniWrite(@AppDataDir & "\ASDFGSupport\ASDFGSupport.ini","Settings","Phone",GUICtrlRead($txtPhone)) IniWrite(@AppDataDir & "\ASDFGSupport\ASDFGSupport.ini","Settings","FullName",GUICtrlRead($txtFullName)) EndFunc func ValidateForm() if GUICtrlRead($txtPhone) = "" Then MsgBox(0,"Required","You must enter a contact phone number.") return False EndIf if GUICtrlRead($txtEmailAddress)="" Then MsgBox(0,"Required","You must enter an email address.") return False EndIf if GUICtrlRead($txtFullName)="" Then MsgBox(0,"Required","You must enter a full name.") return False EndIf if GUICtrlRead($txtSubject)="" Then MsgBox(0,"Required","You must enter a subject.") return False EndIf return True EndFunc func ASDFGSubmit() SaveSettings() dim $respon dim $ah if (@HOUR<9) or (@HOUR >17) or (@WDAY = 7) or (@WDAY = 1) Then $respon = MsgBox(4,"Office Hour (9-5)","Do you require service attended outside this hours ?") ; 6=YES if $respon=6 Then $AfterHour = "Yes" else $AfterHour = "No" EndIf Else $AfterHour = "No" EndIf ;if $isAdminVersion=1 and GUICtrlRead($txtInfo)="" Then ; GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & ASDFGSystemInfo()) ; MsgBox(0,"Administrator","Please review the additional information and then submit again to send incident/ticket.") ; return false ;EndIf dim $PostFileName dim $ScrExt ="" dim $AttExt = "" dim $TestPath Dim $szDrive, $szDir, $szFName, $szExt ; Post Up attached Files. if $gScreenShotFile <> "" Then $TestPath = _PathSplit($gScreenShotFile, $szDrive, $szDir, $szFName, $szExt) $ScrExt = $szExt ; StringRight($gScreenShotFile,3) $PostFileName = "Scr-" & $ASDFGID & $ScrExt UpdateStatus("Uploading ScreenShot") ASDFGFilePost($gScreenShotFile,$PostFileName) EndIf if $gAttachFile <> "" Then $TestPath = _PathSplit($gAttachFile, $szDrive, $szDir, $szFName, $szExt) $AttExt= $szExt ; StringRight($gAttachFile,3) $PostFileName = "Att-" & $ASDFGID & $AttExt UpdateStatus("Uploading Attachment") ASDFGFilePost($gAttachFile,$PostFileName) EndIf ; Now Send the email using ASDFG server :) ;MsgBox(0,"Test",HTTPRequest("http://www.ASDFG.com.au/ASDFGSupport/ConnectionTest.asp","GET","")) dim $URL $URL = "http://www.ASDFG.com.au/ASDFGSupport/SendEmail.asp" dim $eventDes = GUICtrlRead($txtSubject) dim $rmarks = GUICtrlRead($txtDetails) $rmarks &= @CRLF & @CRLF ; Get the info again if $isAdminVersion=0 then $rmarks &= ASDFGSystemInfo() else $rmarks &= GUICtrlRead($txtInfo) endif ; Special version for TC so he can edit the info (no Need just put what you like into the description to test things) ;$rmarks &= GUICtrlRead($txtInfo) $rmarks &= @CRLF & @CRLF $rmarks &= "ScreenShot:" & $gScreenShotFile & @CRLF $rmarks &= "Attachment:" & $gAttachFile & @CRLF dim $Data $Data &= "ASDFGID=" & URIEncode($ASDFGID) $Data &= "&email=" & URIEncode(GUICtrlRead($txtEmailAddress)) $Data &= "&eventDes=" & URIEncode($eventDes) $Data &= "&rmarks=" & URIEncode($rmarks) $Data &= "&Scr=" & URIEncode(StringReplace($ScrExt,".","")) $Data &= "&Att=" & URIEncode(StringReplace($AttExt,".","")) dim $response UpdateStatus("Sending Help Request") $response = HTTPRequest($URL,"POST",$data) if $response<>"OK" Then MsgBox(0,"Error",$response) endIf return ($response="OK") EndFunc func ASDFGSubmitSMTP() dim $JOBID $JOBID = ASDFGGetJobID() SaveSettings() if Number($JOBID)<>0 then dim $CC dim $BCC $CC = "support@ASDFG.com.au" $BCC = "jobs@ASDFG.com.au" dim $FromEmail $FromEmail = GUICtrlRead($txtEmailAddress) ;$CC=$FromEmail dim $ToEmail $ToEmail = $FromEmail ;"tridgeon@ASDFG.com.au" dim $SMTPServer $SMTPServer = "mail.ASDFG.com.au" dim $SMTPUser $SMTPUser = "tridgeon" dim $SMTPPass $SMTPPass = "ASDFG#w3ndy$" dim $AttachFiles ;MsgBox(0,"",$gScreenShotFile) if $gScreenShotFile <> "" Then $AttachFiles = $gScreenShotFile endIf if $gAttachFile <> "" then if $AttachFiles <> "" Then $AttachFiles &= ";" endif $AttachFiles &= $gAttachFile EndIf dim $Body $Body = GUICtrlRead($txtDetails) & @lf & @lf $Body &= "Screenshot Attached:" & ($gScreenShotFile <> "") & @LF $Body &= "File Attached:" & ($gAttachFile <> "") & @lf $Body &= @lf & @lf & ASDFGSystemInfo() $Body = StringAddCR($Body) ;.Subject = "New Job Request - " & cnEvents("@rtnValue") & strTitle dim $Subject = "New Job Request - " & $JOBID & " " & GUICtrlRead($txtSubject) ;$SMTPServer = "192.168.44.10" ;$SMTPUser="" ;$SMTPPass="" ;Func ASDFGSendEmail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", ;$s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", ;$s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) dim $RCode $RCode=ASDFGSendEmail($SMTPServer,"ASDFGHelpButton",$FromEmail,$ToEmail,$Subject,$Body,$AttachFiles,$CC,$BCC,"",$SMTPUser,$SMTPPass) if @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $RCode) Return false Else MsgBox(0,"Help Request Sent","You request for help has been sent.") return true endIf Else MsgBox(0,"Job ID","Unable to get a JobID please try again" & @CRLF & "jobID:" & $JOBID) Return false EndIf EndFunc func AttachFile() dim $FilePath $FilePath = FileOpenDialog("Select File to Attach",@MyDocumentsDir & "\","All (*.*)",1) If @error Then MsgBox(4096,"","No File(s) choosen") Else Return $FilePath EndIf EndFunc func InstallKaseya() ; Download the KaseyaInstall File if FileExists(@TempDir & "\ASDFGAgentsetup.exe") then $InstallPrompt = MsgBox(4,"Ready To Install","Install Kaseya now?") ; 6=YES if $InstallPrompt=6 Then RunWait(@TempDir & "\ASDFGAgentsetup.exe") EndIf Else dim $InstallPrompt $InstallPrompt = MsgBox(4,"Download & Install","Download and install the ASDFG Support Agent") ; 6=YES if $InstallPrompt=6 Then dim $InetGet $InetGet = InetGet("http://agent2.ASDFG.com.au/mkdefault.asp?id=-1",@TempDir & "\ASDFGAgentsetup.exe") ;MsgBox(0,"",@TempDir & " " & $InetGet) EndIf if FileExists(@TempDir & "\ASDFGAgentsetup.exe") then $InstallPrompt = MsgBox(4,"Download Success","Install Kaseya now?") ; 6=YES if $InstallPrompt=6 Then RunWait(@TempDir & "\ASDFGAgentsetup.exe") EndIf EndIf endIf EndFunc func ASDFGSystemInfo() dim $ASDFGInfo $ASDFGInfo = "" & @CRLF if $isAdminVersion=1 then $ASDFGInfo = $ASDFGInfo & @CRLF & " Ticket Tags:" & @CRLF $ASDFGInfo = $ASDFGInfo & "~#userphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF $ASDFGInfo = $ASDFGInfo & "~#submitterphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF dim $MachineID $MachineID = KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","User_Name","NotFound") $ASDFGInfo = $ASDFGInfo & "~#machineid='" & $MachineID & "'" & @CRLF dim $OrgGroups $OrgGroups= StringSplit($MachineID,".") dim $OrgGroupIndex $OrgGroupIndex = UBound($OrgGroups) - 1 $ASDFGInfo = $ASDFGInfo & "~#organization='" & $OrgGroups[$OrgGroupIndex] & "'" & @CRLF dim $EmailUser $EmailUser = GUICtrlRead($txtEmailAddress) $EmailUser = StringMid($EmailUser,1,StringInStr($EmailUser,"@") - 1) & @CRLF & @CRLF $ASDFGInfo = $ASDFGInfo & "~#username='" & $EmailUser & "'" & @CRLF ;dim ;Call("isChecked") ;$categ = GUICtrlRead($chkPatrol) ;$ASDFGInfo = $ASDFGInfo & "-#category='" & $categ & "'" & @CRLF EndIf $ASDFGInfo = $ASDFGInfo & "Email:" & GUICtrlRead($txtEmailAddress) & @CRLF & @CRLF $ASDFGInfo = $ASDFGInfo & "Full Name:" & GUICtrlRead($txtFullName) & @CRLF & @CRLF $ASDFGInfo = $ASDFGInfo & "Phone:" & GUICtrlRead($txtPhone) & @CRLF & @CRLF $ASDFGInfo = $ASDFGInfo & "DateTime:" & _Now() & @CRLF $ASDFGInfo = $ASDFGInfo & "MachineName:" & @ComputerName & @CRLF $ASDFGInfo = $ASDFGInfo & "UserName:" & @UserName & @CRLF $ASDFGInfo = $ASDFGInfo & "OS:" & @OSType & " " & @OSVersion & @CRLF $ASDFGInfo = $ASDFGInfo & "LogonDomain:" & @OSType & " " & @LogonDomain & @CRLF $ASDFGInfo = $ASDFGInfo & "LogonDNSDomain:" & @OSType & " " & @LogonDNSDomain & @CRLF $ASDFGInfo = $ASDFGInfo & "OS:" & @OSType & " " & @OSVersion & @CRLF $ASDFGInfo = $ASDFGInfo & "IP Address:" & @IPAddress1 & @CRLF $ASDFGInfo = $ASDFGInfo & "Public IP Address:" & GetPublicIP() &@CRLF ;$ASDFGInfo = $ASDFGInfo & "Public IP Address:" & _GetIP () &@CRLF $ASDFGInfo = $ASDFGInfo & "OS:" & NetAdapterInfo() $ASDFGInfo = $ASDFGInfo & "KaseyaInstalled:" & KaseyaInstalled() & @CRLF $ASDFGInfo = $ASDFGInfo & "KaseyaRunning:" & KaseyaRunning() & @CRLF $ASDFGInfo = $ASDFGInfo & "KaseyaAgentGUID:" & KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","Agent_Guid","NotFound") & @CRLF $ASDFGInfo = $ASDFGInfo & "ASDFGPaid:" & isASDFGIDPaid() & @CRLF if $isAdminVersion=0 then $ASDFGInfo = $ASDFGInfo & @CRLF & " Ticket Tags:" & @CRLF $ASDFGInfo = $ASDFGInfo & "~userphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF $ASDFGInfo = $ASDFGInfo & "~submitterphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF dim $MachineID $MachineID = KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","User_Name","NotFound") $ASDFGInfo = $ASDFGInfo & "~machineid='" & $MachineID & "'" & @CRLF dim $OrgGroups $OrgGroups= StringSplit($MachineID,".") dim $OrgGroupIndex $OrgGroupIndex = UBound($OrgGroups) - 1 $ASDFGInfo = $ASDFGInfo & "~organization='" & $OrgGroups[$OrgGroupIndex] & "'" & @CRLF dim $EmailUser $EmailUser = GUICtrlRead($txtEmailAddress) $EmailUser = StringMid($EmailUser,1,StringInStr($EmailUser,"@") - 1) $ASDFGInfo = $ASDFGInfo & "~username='" & $EmailUser & "'" & @CRLF dim $categ $categ = GUICtrlRead($chkPatrol) $ASDFGInfo = $ASDFGInfo & "~category='" & $categ & "'" & @CRLF $ASDFGInfo = $ASDFGInfo & "~afterhour='" & $AfterHour & "'" & @CRLF endif Return $ASDFGInfo endFunc func KaseyaIni($pFileName,$pSection,$pKey,$pDefault) $file = FileOpen($pFileName, 0) ; Check if file opened for reading OK If $file = -1 Then Return $pDefault Exit EndIf ; Read in lines of text until the EOF is reached $SectionFound = False $KeyFound=False While 1 $line = FileReadLine($file) if StringInStr($Line,"[" & $pSection & "]") >0 Then $SectionFound=True EndIf if $SectionFound and StringInStr($Line,$pKey) >0 Then $KeyFound=true ExitLoop endIf If @error = -1 Then ExitLoop ;MsgBox(0, "Line read:", $line) Wend FileClose($file) if $SectionFound and $KeyFound Then $line=StringRegExpReplace($line,"\s+","=") $line=StringSplit($line,"=") $line=$line[2] return $line Else Return $pDefault EndIf EndFunc func KaseyaRunning() dim $KaseyaProcessName $KaseyaProcessName = "AgentMon.exe" ;$KaseyaProcessName = "SciTe.exe" dim $KaseyaOK $KaseyaOK = ProcessExists($KaseyaProcessName) <> 0 Return $KaseyaOK EndFunc func KaseyaInstalled() dim $KaseyaUserName $KaseyaUserName= KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","User_Name","NotInstalled") ;return false Return $KaseyaUserName <> "NotInstalled" EndFunc func GetKaseyaDIni() dim $Search $Search = ScanFolder(@ProgramFilesDir & "\Kaseya","Kaseyad.ini") return $Search EndFunc Func ScanFolder($SourceFolder,$FindFileName) Local $Search Local $File Local $FileAttributes Local $FullFilePath $Search = FileFindFirstFile($SourceFolder & "\*.*") dim $FoundFile $FoundFile="" While 1 If $Search = -1 Then ExitLoop EndIf $File = FileFindNextFile($Search) If @error Then ExitLoop $FullFilePath = $SourceFolder & "\" & $File $FileAttributes = FileGetAttrib($FullFilePath) If StringInStr($FileAttributes,"D") Then $FoundFile = ScanFolder($FullFilePath,$FindFileName) Else ;MsgBox(0,"",$FullFilePath) if StringInStr($FullFilePath,$FindFileName) Then $FoundFile = $FullFilePath ExitLoop EndIf EndIf WEnd FileClose($Search) return $FoundFile EndFunc func HasInternetConnection() ;Internet Available dim $INetData ;$INetData = InetRead("http://www.ASDFG.com.au/ASDFGSupport/ConnectionTest.asp") $INetData = HTTPRequest("http://www.ASDFG.com.au/ASDFGSupport/ConnectionTest.asp","GET","") dim $InetText $InetText = BinaryToString($INetData) if $InetText="Internet Available" Then return true Else ; try to connect to another know service ;$INetData = InetRead("http://www.google.com") $INetData = HTTPRequest("http://www.google.com","GET","") $InetText = BinaryToString($INetData) if StringInStr($InetText,"google")>0 Then return true Else return False EndIf EndIf EndFunc func isASDFGIDPaid() ; Check to see if they Paid. ;MsgBox(0,"",$ASDFGID) dim $tic $tic = _TimeToTicks() Dim $ASDFGIDPaidData ;$ASDFGIDPaidData = InetRead("http://www.ASDFG.com.au/ASDFGSupport/CheckPaid.asp?ASDFGID=" & $ASDFGID & "&UserName=" & @UserName & "&tick=" & $tic) $ASDFGIDPaidData = HTTPRequest("http://www.ASDFG.com.au/ASDFGSupport/CheckPaid.asp?ASDFGID=" & $ASDFGID & "&UserName=" & @UserName & "&tick=" & $tic,"GET","") dim $ASDFGIDPaid $ASDFGIDPaid = BinaryToString($ASDFGIDPaidData) ;MsgBox(0,"Paid=",$ASDFGIDPaid) if $ASDFGIDPaid = "Paid" Then return True Else return false EndIf EndFunc func GetASDFGID() ; looks for the ASDFGID or generates a new one dim $file dim $ASDFGFile $ASDFGFile = @AppDataDir & "\ASDFGSupport\ASDFGID.txt" ;MsgBox(0,"",$ASDFGFile) if FileExists($ASDFGFile)=0 Then ;MsgBox(0,"","Create ASDFGID") DirCreate(@AppDataDir & "\ASDFGSupport") $file = FileOpen($ASDFGFile,2) FileWriteLine($file,CreateGuid()) FileClose($file) endif $file=FileOpen($ASDFGFile,0) dim $ASDFGID $ASDFGID = FileReadLine($file) FileClose($file) return $ASDFGID endFunc Func SaveScreenShot() ; Capture full screen GUISetState(@SW_MINIMIZE,$Form1_1) Sleep(1000) dim $ScreenShotFile $ScreenShotFile = @AppDataDir & "\ASDFGSupport\ScreenShot.jpg" ;_ScreenCapture_Capture($ScreenShotFile) _ScreenCapture_Capture($ScreenShotFile, $Left, $Top, $Right, $Bottom) GUISetState(@SW_RESTORE,$Form1_1) return $ScreenShotFile EndFunc Func CreateGuid() Local $Guid = DllStructCreate($tagGUID) $Result = DllCall("OLE32.DLL", "dword", "CoCreateGuid", "ptr", DllStructGetPtr($Guid)) $Result = _WinAPI_StringFromGUID(DllStructGetPtr($Guid)) Return $Result EndFunc Func ASDFGSendEmail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" EndFunc ;==>_INetSmtpMailCom ; Generated by AutoIt Scriptomatic func NetAdapterInfo() $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $strDefaultIPGateway = $objItem.DefaultIPGateway(0) if $strDefaultIPGateway Then $Output = $Output & "Net-Description: " & $objItem.Description & @CRLF $strIPAddress = $objItem.IPAddress(0) $Output = $Output & "Net-IPAddress: " & $strIPAddress & @CRLF $Output = $Output & "Net-DefaultIPGateway: " & $strDefaultIPGateway & @CRLF $Output = $Output & "Net-MACAddress: " & $objItem.MACAddress & @CRLF EndIf Next Return $Output Else Return "" Endif endFunc ;~ $Output = $Output & "#########################################################################" & @CRLF ;~ $Output = $Output & "#########################################################################" & @CRLF ;~ $Output = $Output & "ArpAlwaysSourceRoute: " & $objItem.ArpAlwaysSourceRoute & @CRLF ;~ $Output = $Output & "ArpUseEtherSNAP: " & $objItem.ArpUseEtherSNAP & @CRLF ;~ $Output = $Output & "Caption: " & $objItem.Caption & @CRLF ;~ $Output = $Output & "DatabasePath: " & $objItem.DatabasePath & @CRLF ;~ $Output = $Output & "DeadGWDetectEnabled: " & $objItem.DeadGWDetectEnabled & @CRLF ;~ $strDefaultIPGateway = $objItem.DefaultIPGateway(0) ;~ $Output = $Output & "DefaultIPGateway: " & $strDefaultIPGateway & @CRLF ;~ $Output = $Output & "DefaultTOS: " & $objItem.DefaultTOS & @CRLF ;~ $Output = $Output & "DefaultTTL: " & $objItem.DefaultTTL & @CRLF ;~ $Output = $Output & "Description: " & $objItem.Description & @CRLF ;~ $Output = $Output & "DHCPEnabled: " & $objItem.DHCPEnabled & @CRLF ;~ $Output = $Output & "DHCPLeaseExpires: " & WMIDateStringToDate($objItem.DHCPLeaseExpires) & @CRLF ;~ $Output = $Output & "DHCPLeaseObtained: " & WMIDateStringToDate($objItem.DHCPLeaseObtained) & @CRLF ;~ $Output = $Output & "DHCPServer: " & $objItem.DHCPServer & @CRLF ;~ $Output = $Output & "DNSDomain: " & $objItem.DNSDomain & @CRLF ;~ $strDNSDomainSuffixSearchOrder = $objItem.DNSDomainSuffixSearchOrder(0) ;~ $Output = $Output & "DNSDomainSuffixSearchOrder: " & $strDNSDomainSuffixSearchOrder & @CRLF ;~ $Output = $Output & "DNSEnabledForWINSResolution: " & $objItem.DNSEnabledForWINSResolution & @CRLF ;~ $Output = $Output & "DNSHostName: " & $objItem.DNSHostName & @CRLF ;~ $strDNSServerSearchOrder = $objItem.DNSServerSearchOrder(0) ;~ $Output = $Output & "DNSServerSearchOrder: " & $strDNSServerSearchOrder & @CRLF ;~ $Output = $Output & "DomainDNSRegistrationEnabled: " & $objItem.DomainDNSRegistrationEnabled & @CRLF ;~ $Output = $Output & "ForwardBufferMemory: " & $objItem.ForwardBufferMemory & @CRLF ;~ $Output = $Output & "FullDNSRegistrationEnabled: " & $objItem.FullDNSRegistrationEnabled & @CRLF ;~ $strGatewayCostMetric = $objItem.GatewayCostMetric(0) ;~ $Output = $Output & "GatewayCostMetric: " & $strGatewayCostMetric & @CRLF ;~ $Output = $Output & "IGMPLevel: " & $objItem.IGMPLevel & @CRLF ;~ $Output = $Output & "Index: " & $objItem.Index & @CRLF ;~ $strIPAddress = $objItem.IPAddress(0) ;~ $Output = $Output & "IPAddress: " & $strIPAddress & @CRLF ;~ $Output = $Output & "IPConnectionMetric: " & $objItem.IPConnectionMetric & @CRLF ;~ $Output = $Output & "IPEnabled: " & $objItem.IPEnabled & @CRLF ;~ $Output = $Output & "IPFilterSecurityEnabled: " & $objItem.IPFilterSecurityEnabled & @CRLF ;~ $Output = $Output & "IPPortSecurityEnabled: " & $objItem.IPPortSecurityEnabled & @CRLF ;~ $strIPSecPermitIPProtocols = $objItem.IPSecPermitIPProtocols(0) ;~ $Output = $Output & "IPSecPermitIPProtocols: " & $strIPSecPermitIPProtocols & @CRLF ;~ $strIPSecPermitTCPPorts = $objItem.IPSecPermitTCPPorts(0) ;~ $Output = $Output & "IPSecPermitTCPPorts: " & $strIPSecPermitTCPPorts & @CRLF ;~ $strIPSecPermitUDPPorts = $objItem.IPSecPermitUDPPorts(0) ;~ $Output = $Output & "IPSecPermitUDPPorts: " & $strIPSecPermitUDPPorts & @CRLF ;~ $strIPSubnet = $objItem.IPSubnet(0) ;~ $Output = $Output & "IPSubnet: " & $strIPSubnet & @CRLF ;~ $Output = $Output & "IPUseZeroBroadcast: " & $objItem.IPUseZeroBroadcast & @CRLF ;~ $Output = $Output & "IPXAddress: " & $objItem.IPXAddress & @CRLF ;~ $Output = $Output & "IPXEnabled: " & $objItem.IPXEnabled & @CRLF ;~ $strIPXFrameType = $objItem.IPXFrameType(0) ;~ $Output = $Output & "IPXFrameType: " & $strIPXFrameType & @CRLF ;~ $Output = $Output & "IPXMediaType: " & $objItem.IPXMediaType & @CRLF ;~ $strIPXNetworkNumber = $objItem.IPXNetworkNumber(0) ;~ $Output = $Output & "IPXNetworkNumber: " & $strIPXNetworkNumber & @CRLF ;~ $Output = $Output & "IPXVirtualNetNumber: " & $objItem.IPXVirtualNetNumber & @CRLF ;~ $Output = $Output & "KeepAliveInterval: " & $objItem.KeepAliveInterval & @CRLF ;~ $Output = $Output & "KeepAliveTime: " & $objItem.KeepAliveTime & @CRLF ;~ $Output = $Output & "MACAddress: " & $objItem.MACAddress & @CRLF ;~ $Output = $Output & "MTU: " & $objItem.MTU & @CRLF ;~ $Output = $Output & "NumForwardPackets: " & $objItem.NumForwardPackets & @CRLF ;~ $Output = $Output & "PMTUBHDetectEnabled: " & $objItem.PMTUBHDetectEnabled & @CRLF ;~ $Output = $Output & "PMTUDiscoveryEnabled: " & $objItem.PMTUDiscoveryEnabled & @CRLF ;~ $Output = $Output & "ServiceName: " & $objItem.ServiceName & @CRLF ;~ $Output = $Output & "SettingID: " & $objItem.SettingID & @CRLF ;~ $Output = $Output & "TcpipNetbiosOptions: " & $objItem.TcpipNetbiosOptions & @CRLF ;~ $Output = $Output & "TcpMaxConnectRetransmissions: " & $objItem.TcpMaxConnectRetransmissions & @CRLF ;~ $Output = $Output & "TcpMaxDataRetransmissions: " & $objItem.TcpMaxDataRetransmissions & @CRLF ;~ $Output = $Output & "TcpNumConnections: " & $objItem.TcpNumConnections & @CRLF ;~ $Output = $Output & "TcpUseRFC1122UrgentPointer: " & $objItem.TcpUseRFC1122UrgentPointer & @CRLF ;~ $Output = $Output & "TcpWindowSize: " & $objItem.TcpWindowSize & @CRLF ;~ $Output = $Output & "WINSEnableLMHostsLookup: " & $objItem.WINSEnableLMHostsLookup & @CRLF ;~ $Output = $Output & "WINSHostLookupFile: " & $objItem.WINSHostLookupFile & @CRLF ;~ $Output = $Output & "WINSPrimaryServer: " & $objItem.WINSPrimaryServer & @CRLF ;~ $Output = $Output & "WINSScopeID: " & $objItem.WINSScopeID & @CRLF ;~ $Output = $Output & "WINSSecondaryServer: " & $objItem.WINSSecondaryServer & @CRLF Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc #comments-start #comments-end Func ASDFGFilePost($pSourceFile,$pDestFileName) dim $FileData $FileData = GetFile($pSourceFile) PUTFileData($pDestFileName,$FileData) endFunc func GetFile($pFileName) Dim $Stream; Set Stream = CreateObject("ADODB.Stream") $Stream = ObjCreate("ADODB.Stream") $Stream.Type = 1 ;Binary $Stream.Open $Stream.LoadFromFile($pFileName) dim $StreamData $StreamData = $Stream.Read $Stream.Close $Stream="" return $StreamData endfunc func PUTFileData($pFilename,$pData) Dim $xmlhttp $xmlhttp=ObjCreate("MSXML2.XMLHTTP.3.0") dim $strURL $strURL= "http://www.ASDFG.com.au/ASDFGSupport/Upload/" & $pFilename $xmlhttp.Open ("PUT", $strURL, False) $xmlhttp.Send ($pData) $xmlhttp="" EndFunc func HTTPRequest($pURL,$pMethod,$pData) $pMethod=StringUpper($pMethod) Dim $xmlhttp $xmlhttp=ObjCreate("MSXML2.XMLHTTP.3.0") $xmlhttp.Open (StringUpper($pMethod), $pURL, False) if $pMethod="POST" then ;MsgBox(0,"","POST") $xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded") endIf $xmlhttp.Send ($pData) dim $Response $Response = $xmlhttp.responseText() $xmlhttp="" ConsoleWrite ($pData) Return $Response EndFunc func UpdateStatus($pText) GUICtrlSetData($lblConnected,$pText) EndFunc func GetPublicIP() $url = "https://api.ipify.org" $ipstring = HTTPRequest($url,"GET","") Return $ipstring EndFunc