; Computer LWS Decommission Script #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include Global $EnterPCNames, $ReadExcelNames, $ManuallyChecked, $ExcelReadChecked Opt("TrayAutoPause", 0) Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL, $MB_TOPMOST), "SLHS Computer Removal", "This is the SLHS Computer Removal script Hit Yes to Continue. Hit No if you do not wish to run this script.") MsgBox(BitOR($MB_OK, $MB_SYSTEMMODAL, $MB_TOPMOST), "Make sure Text is set to LWS main Menu.", "Hit Ok once Text is set to LWS and its left on the main Menu.") ;***************************************************************************************************** ;----------------Map T drive if its not Mapped------------------------------ Might not need this and can take out later on. If $iAnswer = 7 Then MsgBox($MB_SYSTEMMODAL, "AutoIt", "Exiting script.") Exit EndIf DriveMapGet("T:") If @error = 1 Then ;msgbox(0,"result", "NOT MAPPED") DriveMapAdd("T:", "\\fs1cle\tech") Else ;msgbox(0,"result", "MAPPED") EndIf ;***************************************************************************************************** ; Initial GUI Setup Global $aTaskbarinit = WinGetPos("[CLASS:Shell_TrayWnd]", "") $Window = GUICreate("Choose the method of entering the PC names:", 440, 100, @DesktopWidth, @DesktopHeight) WinSetOnTop("Choose the method of entering the PC names:", "", 1) Global $aWinInitGui = WinGetPos($Window) $EnterPCNames = GUICtrlCreateCheckbox("Enter PC Names in Manually.", 8, 8, 160, 17) $ReadExcelNames = GUICtrlCreateCheckbox("Read all names from an Excel File.", 8, 32, 180, 17) ;41,17 Global $GUIContinueButton = GUICtrlCreateButton("Continue", 8, 65, 75, 25, $WS_GROUP) ; Move the Initial GUI to the bottom right WinMove($Window, "", @DesktopWidth - $aWinInitGui[2] - 4, @DesktopHeight - $aWinInitGui[3] - $aTaskbarinit[3] - 4) GUISetState(@SW_SHOW) Sleep(2000) ;---------------------------------------------------------------------------------------------------------------------------- ;-------------------Is checked for each box0------------ $ManuallyChecked = GUICtrlRead($EnterPCNames) $ExcelReadChecked = GUICtrlRead($ReadExcelNames) ;Global $CurrUser = StringMid("Currently logged in User: " & _GetConsoleUser(), 31, 6) ; Find out which ones were checked and pull out the name of the Printer. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUIContinueButton If GUICtrlRead($EnterPCNames) = $GUI_CHECKED Then ;GUICtrlSetData($ManuallyChecked, 'Checked') ManualEntryFunc() Sleep(2000) Else GUICtrlSetData($EnterPCNames, 'Unchecked') EndIf If GUICtrlRead($ReadExcelNames) = $GUI_CHECKED Then ;GUICtrlSetData($EpicChecked, 'Checked') ExcelEntriesFunc() Sleep(2000) Else GUICtrlSetData($ReadExcelNames, 'Unchecked') EndIf ExitLoop EndSwitch WEnd GUISetState(@SW_ENABLE) GUIDelete($Window) Func ManualEntryFunc() Local $PCname, $PCNameLabel, $PCNameInput, $PCNameView, $GUIContinueButton, $iAnswer, $RNDM, $AVNumber ; Remove the initial Window. GUISetState(@SW_ENABLE) GUIDelete($Window) ;Create the Window to enter the single computer name------------------------------------------------ ; Initial GUI Setup Global $aTaskbarinit = WinGetPos("[CLASS:Shell_TrayWnd]", "") $SinglePCGUI = GUICreate("PC Name to Decommission LWS", 440, 100, @DesktopWidth, @DesktopHeight) WinSetOnTop("Please enter the Computer name to Decommission:", "", 1) Global $aWinInitGui = WinGetPos($SinglePCGUI) ;$EnterPCNames = GUICtrlCreateCheckbox("Enter PC Names in Manually.", 8, 8, 160,17) Local $PCNameLabel = GUICtrlCreateLabel("Enter PC name being removed: ", 8, 15, 165, 20) Local $PCNameInput = GUICtrlCreateInput("", 175, 15, 100, 20) ; 80,20 Local $GUIContinueButton = GUICtrlCreateButton("Continue", 8, 65, 75, 25, $WS_GROUP) ; Move the Initial GUI to the bottom right WinMove($SinglePCGUI, "", @DesktopWidth - $aWinInitGui[2] - 4, @DesktopHeight - $aWinInitGui[3] - $aTaskbarinit[3] - 4) GUISetState(@SW_SHOW) Sleep(2000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUIContinueButton If GUICtrlRead($PCNameInput) = "" Then Local $PCNameLabel = GUICtrlCreateLabel("No computer name entered. ", 8, 35, 165, 20) Sleep(5000) ManualEntryFunc() Else $PCNameView = GUICtrlRead($PCNameInput) WinActivate("You are connected to Epic ""PROD"" Environment", "") ; Activate the Chronicles window Sleep(2000) WinSetState("You are connected to Epic ""PROD"" Environment", "", @SW_ENABLE) Send("{ENTER}" & "{ENTER}" & "11" & "{ENTER}" & "LWS" & "{ENTER}" & "1") Sleep(2000) Send("{ENTER}" & "1" & "{ENTER}" & "1" & "{ENTER}") ; Should be at the Workstation LWS prompt at this time. Now Remove all Entries. ;------------------------------------------------------------------------------------------------------------------------------------- Sleep(2000) Send($PCNameView & "{ENTER}") ;------------Find out if the computer name has an LWS or not and remove it if it does. Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL, $MB_TOPMOST), "LWS Exists?", "Does this computer have an lws. (Yes/No)") If $iAnswer = 7 Then ; No Answer MsgBox($MB_SYSTEMMODAL, "PC Decommission", "There is no LWS for this PC name.") Sleep(5000) Exit Else ;Yes Answer Send("{home down}" & "{F9}" & sleep(1000) & "{home up}" & "i") Send("{ENTER}" & "52216" & "{ENTER}" & "100000" & "{ENTER}") ;Set 100000-SLHS COMBINATION FDI sleep(2000) Send("{PGUP 7}" & "{ENTER}" & "{F1}") ;Set Exam room workstation: sleep(2000) Send("{PGUP 2}" & "{F1}" & "{ENTER 2}" & "{F1 20}") ;Set Default OTG to Empty and same with additional departments sleep(2000) Send("{PGUP 5}" & "{F1 5}" & "{ENTER 2}" & "{F1 60}") ; Remove all print groups and classifications. Sleep(4000) Send("{PGUP 10}" & "{F1}" & "{ENTER}" & "{DOWN 2}" & "{TAB}" & "No") ; Remove setting for epic hyperspace timeout sleep(4000) Send("{PGUP}" & "{F1}" & "{ENTER}" & "{F1}" & "{ENTER}") ;Remove Department and Profile Department sleep(2000) send("{PGUP}" & "{DOWN 3}" & "{F1}" & "Inactive" & "{ENTER}") ; Generate random number between 1000 and 80000 then ad the AV to front and ask user if there was an error and if so then regenerate and retry. ; This area will create a random number, See if that AV###### has an lws and then verify if it exists. If it does exist ;then it will create another one and look again. Local $AVTaken = "yes" While $AVTaken == "yes" $RNDM = Random(1000, 800000, 1) ; Return an integer between 5 and 20 to determine the length of the string. Local $AVNumber = ("AV" & $RNDM) Send("{UP 2}" & "{F1}" & $AVNumber & "{ENTER}") Sleep(2000) Local $AVAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL, $MB_TOPMOST), "LWS Exists for AV###?", "Is there an lws already for this AV###? (Yes/No)") if $AVAnswer == "7" Then sleep(2000) Send("{UP 3}" & "{F1}" & $AVNumber & "{ENTER}") $AVTaken = "no" Sleep(2000) Exit EndIf sleep(2000) WEnd EndIf EndIf EndSwitch WEnd EndFunc ;==>ManualEntryFunc ;----------------Multiple PC name sheet entries----------------------- Func ExcelEntriesFunc() EndFunc ;==>ExcelEntriesFunc ;ExcelEntriesFunc()