#include #include #include #include #include #include #include #include #include #include #include #include #include Opt ("TrayAutoPause",0) ; READ SERVERS.INI ########==> Local $aServers = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") ; GUI WIDTH AND HEIGHT ########==> $width = 365 $height = 553 ; Create Main GUI and TabControl $Form1 = GUICreate("Magasin - Hotline Tools v1.0 (beta)", $width, $height, @DesktopWidth - ($width + 20), 5, $WS_OVERLAPPEDWINDOW + $WS_CLIPCHILDREN) $PageControl1 = GUICtrlCreateTab(8, 8, 350, 539) ; ViKING Tab ########==> $ViKING = GUICtrlCreateTabItem("ViKING Controller") $EC = GUICtrlCreateButton("Enterprise Controller (EC)", 28, 73, 304, 25) $KN = GUICtrlCreateButton("Kongens Nytorv - 10", 28, 107, 304, 25) $FI = GUICtrlCreateButton("Fields - 25", 28, 141, 304, 25) $LY = GUICtrlCreateButton("Lyngby - 20", 28, 174, 304, 25) $RO = GUICtrlCreateButton("Rødovre - 30", 28, 208, 304, 25) $OD = GUICtrlCreateButton("Odense - 40", 28, 242, 304, 25) $AR = GUICtrlCreateButton("Århus - 50", 28, 276, 304, 25) $ALLMC = GUICtrlCreateButton("Åben alle MC´s", 28, 309, 304, 25) $ViKTEST = GUICtrlCreateButton("ViKING Testserver", 28, 344, 304, 25) $vikProd = GUICtrlCreateButton("Chek Vikingprod failed folder", 28, 377, 304, 25) $vikprodPath = ("\\mahiis31\internalFTP\Vikingprod\failed") ; Tools Tab ########==> $Tools = GUICtrlCreateTabItem("Helpdesk Tools") $btn_OfferRemote = GUICtrlCreateButton("Offer Remote Assistance", 28, 73, 304, 25) $btn_UserPcName = GUICtrlCreateButton("Find Bruger og Computernavn", 28, 107, 304, 25) $btn_gpupdate = GUICtrlCreateButton("GPUPDATE", 28, 141, 304, 25) $btn_Topdesk = GUICtrlCreateButton("Topdesk Helpdesk", 28, 174, 304, 25) $btn_Ikano = GUICtrlCreateButton("Ikano Store Portal", 28, 208, 304, 25) $btn_pass = GUICtrlCreateButton("Service Accounts", 28, 242, 304, 25) ; Servers Tab ########==> $Servers = GUICtrlCreateTabItem("Servers/Hosts") $listview_srv = GUICtrlCreateListView("Server/Host|IP|Status", 20, 50, 322, 420, $LVS_SINGLESEL,$LVS_EX_GRIDLINES+$LVS_SORTDESCENDING) _GuiCtrlListView_SetColumnWidth($listview_srv,0,130) _GuiCtrlListView_SetColumnWidth($listview_srv,1,90) _GuiCtrlListView_SetColumnWidth($listview_srv,2,90) $btn_srv_AddServer = GUICtrlCreateButton("Add Host", 20, 480, 94, 25) GUICtrlSetOnEvent(-1, "AddServer") $btn_srv_RemoveServer = GUICtrlCreateButton("Remove Host", 120, 480, 94, 25) GUICtrlSetOnEvent(-1, "RemoveServer") $btn_srv_RefreshList = GUICtrlCreateButton("Refresh List", 220, 480, 94, 25) GUICtrlSetOnEvent(-1, "RefreshServer") $btn_srv_Connect = GUICtrlCreateButton("Connect", 20, 510, 94, 25) GUICtrlSetOnEvent(-1, "ConnectToServer") $btn_srv_Ping = GUICtrlCreateButton("Ping -t", 120, 510, 94, 25) GUICtrlSetOnEvent(-1, "PingServer") $btn_srv_Clear = GUICtrlCreateButton("Clear List", 220, 510, 94, 25) GUICtrlSetOnEvent(-1, "ClearList") ; About Tab ########==> $About = GUICtrlCreateTabItem("About") ; Main GUI Control ########==> GUISetState(@SW_SHOW) ;SetIp() ;GetServers() ;RefreshServer() ;GetStatus() AdlibRegister("SetIp",10000) AdlibRegister("GetServers",10000) AdlibRegister("RefreshServer",10000) AdlibRegister("GetStatus",10000) While 1 $nMsg = GUIGetMsg(1) Switch $nMsg Case $GUI_EVENT_CLOSE Exit ; --> VIKING ########==> Case $EC ShellExecute ("C:\K95\ViKING EC.lnk") Send("ec") Case $KN ShellExecute ("C:\K95\ViKING KGS.Nytorv.lnk") Case $FI ShellExecute ("C:\K95\ViKING Fields.lnk") Case $LY ShellExecute ("C:\K95\ViKING Lyngby.lnk") Case $RO ShellExecute ("C:\K95\ViKING Rødovre.lnk") Case $OD ShellExecute ("C:\K95\ViKING Odense.lnk") Case $AR ShellExecute ("C:\K95\ViKING Århus.lnk") Case $ALLMC ShellExecute ("C:\K95\ViKING KGS.Nytorv.lnk") ShellExecute ("C:\K95\ViKING Fields.lnk") ShellExecute ("C:\K95\ViKING Lyngby.lnk") ShellExecute ("C:\K95\ViKING Rødovre.lnk") ShellExecute ("C:\K95\ViKING Odense.lnk") ShellExecute ("C:\K95\ViKING Århus.lnk") Case $ViKTEST If FileExists ("C:\K95\ViKING Test.lnk") Then ShellExecute ("C:\K95\ViKING Test.lnk") Else MsgBox (0,"Fejl med genvej","Hovsa! Det ser ud som om at genvejen til ViKING testserveren mangler eller er navngivet forkert. Chek at genvejen C:\K95\ViKING Test.lnk eksistere eller kontakt en POS ansvarlig fra IT") EndIf Case $vikProd vikprod() ; --> SERVERS ########==> Case $btn_srv_AddServer addServer() Case $btn_srv_RefreshList RefreshServer() Case $btn_srv_RemoveServer RemoveServer() Case $btn_srv_Connect ConnectToServer() Case $btn_srv_Ping PingServer() Case $btn_srv_Clear If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(4,"Clear Server List","Dette vil slette hele listen! er du sikker?") Select Case $iMsgBoxAnswer = 6 ;Yes Case $iMsgBoxAnswer = 7 ;No EndSelect if $iMsgBoxAnswer = 6 Then ClearList() Else EndIf ; --> TOOLS ########==> Case $btn_OfferRemote ShellExecute ("C:\Windows\System32\msra.exe"," /offerRA") Case $btn_UserPcName ShellExecute ("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Magasin\Bruger og Computer Info.lnk") Case $btn_gpupdate ShellExecute ("C:\Windows\System32\gpupdate.exe", "/force") Case $btn_Topdesk ShellExecute ("http://helpdesk") Case $btn_Ikano ShellExecute ("https://application.ikanobank.nu/plus-sportal-dk/sportal/login.jsf?prodCode=MGDK&conversationId=1545309") Case $btn_pass ShellExecute ("T:\itafd\!DOKUMENTATION IT DRIFT\MagasinDanmark beskrivelse\Service Accounts.xlsx") EndSwitch WEnd ;################################# FUNCTIONS ###########################################==> ; ; ; ADD SERVER / HOST ########==> Func addServer () $hGuiAddServer = GUICreate ("Add Server") $NewServer = InputBox ("Add Server or Host","Please type hostname","","",-1,-1,Default,Default,"",$hGuiAddServer) $NewServer = StringUpper($NewServer) TCPStartup() $ipAddress = TCPNameToIP ($NewServer) TCPShutdown() if Not $NewServer="" Then IniWrite (@ScriptDir & "\Servers.ini", "Servers", $NewServer, $ipAddress) EndIf While 4 $sMsg = GUIGetMsg($NewServer) Switch $sMsg Case $GUI_EVENT_CLOSE GUICtrlDelete($hGuiAddServer) EndSwitch ExitLoop WEnd _GUICtrlListView_DeleteAllItems($listview_srv) $sItem_srv = GUICtrlRead(GUICtrlRead($listview_srv)) GetServers() GetStatus() EndFunc ; REMOVE SERVER / HOST ########==> Func RemoveServer() Local $hot_Item = _GUICtrlListView_GetSelectionMark($listview_srv) Local $sItem_srv = _GUICtrlListView_GetItemText($listview_srv, $hot_Item) Local $iniRead = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") IniDelete (@ScriptDir & "\Servers.ini","Servers",$sItem_srv) _GUICtrlListView_DeleteAllItems($listview_srv) $sItem_srv = GUICtrlRead(GUICtrlRead($listview_srv)) GetServers() GetStatus() EndFunc ; CONNECT TO SERVER / HOST ########==> Func ConnectToServer() Local $hot_Item = _GUICtrlListView_GetSelectionMark($listview_srv) Local $sItem_srv = _GUICtrlListView_GetItemText($listview_srv, $hot_Item) Local $iniRead = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") if not @error Then ShellExecute("mstsc.exe","/admin /v "&$sItem_srv) EndIf EndFunc ; DELETE LISTVIEW AND RUN FUNCTIONS TO GET IP´S AND CREATE LISTVIEW AGAIN ########==> Func RefreshServer() _GUICtrlListView_DeleteAllItems($listview_srv) $sItem_srv = GUICtrlRead(GUICtrlRead($listview_srv)) SetIp() GetServers() GetStatus() EndFunc ; GET HOSTS FROM INI FILE AND WRITE TO LISTVIEW ########==> Func GetServers() Local $aServers = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") _GUICtrlListView_DeleteAllItems($listview_srv) If Not @error Then For $i = 1 To $aServers[0][0] GUICtrlCreateListViewItem($aServers[$i][0] & '|' & $aServers[$i][1], $listview_srv) Next EndIf EndFunc ; SET IP ON HOSTS THATS MISSING ONE ########==> Func SetIp() $IpToHost = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") If Not @error Then For $i = 1 To $IpToHost[0][0] if $IpToHost[$i][1] = 0 Then TCPStartup() $SetIP = TCPNameToIP ($IpToHost[$i][0]) IniWrite(@ScriptDir & "\Servers.ini", "Servers", $IpToHost[$i][0], $SetIp) TCPShutdown() EndIf Next EndIf EndFunc ; PING HOST WITH -T ########==> Func PingServer() Local $hot_Item = _GUICtrlListView_GetSelectionMark($listview_srv) Local $sItem_srv = _GUICtrlListView_GetItemText($listview_srv, $hot_Item) Local $iniRead = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") ShellExecute ("C:\Windows\System32\cmd.exe",'/c Ping '& $sItem_srv &' -t',"C:\Windows\System32") EndFunc ; DELETES THE SERVERLIST ########==> Func ClearList() _GUICtrlListView_DeleteAllItems($listview_srv) IniDelete(@ScriptDir & "\Servers.ini", "Servers") EndFunc ; CHECKS A FOLDER ########==> Func vikprod() $sizefldr1 = DirGetSize($vikprodPath, 1) If Not @error Then If Not $sizefldr1[1] And Not $sizefldr1[2] Then MsgBox(0,"ViKING Prod Status","Der er ingen filer i mappen: " & $vikprodPath) ElseIf Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(4,"ViKING Prod Status", "Der er en eller flere filer i mappen: " & $vikprodPath & " Vil du gå til mappen?") Select Case $iMsgBoxAnswer = 6 ;Yes Case $iMsgBoxAnswer = 7 ;No EndSelect If $iMsgBoxAnswer = 6 Then Run("Explorer.exe " & $vikprodPath) EndIf EndIf EndIf EndFunc ; GET STATUS OF HOST: OFFLINE / ONLINE AND WRITE TO LISTVIEW ########==> Func GetStatus() Local $iniRead = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") For $i = 0 To $iniRead[0][0] $Ip = $iniRead[$i][1] Local $iPing = Ping($Ip, 2000) ;MsgBox(0, "$Ip = ", $Ip) ;MsgBox(0, "@error", @Error) If $iPing > 0 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Online", 2) If @error = 1 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Offline", 2) If @error = 2 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Unreachable", 2) If @error = 3 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Bad Destination", 2) If @error = 4 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Error", 2) If $Ip = "" Then _GUICtrlListView_AddSubItem($listview_srv, $i, "IP Missing", 2) EndIf EndIf EndIf EndIf EndIf EndIf Next EndFunc