Script works on Win10 but not Win7 (please help a girl out!!)

Get help with using AutoHotkey and its commands and hotkeys
User avatar
coder_chick
Posts: 185
Joined: 05 Nov 2015, 10:43

Script works on Win10 but not Win7 (please help a girl out!!)

21 May 2019, 10:50

I have a script where the GUI opens and the app works perfectly on a Windows 10 machine, but when I compile and bring to Windows 7 and Win Server, the app runs, displays msgbox, and GUI opens to taskbar and doesn't show and can't be maximized. What am I missing? Why isn't the GUI showing?

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance,Force
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.



AppTitle = Exchange Mailbox Puller - v2.6


SECTION1:
SetWorkingDir %A_ScriptDir%
FormatTime, TimeString, , yyyyMMdd
SetBatchLines -1 ; Runs the script at maximum speed

MsgBox, 262208, %AppTitle%, This app is used to auto-generate a batch file that can be run to pull select mailboxes from Exchange.`n`nYou should run the Exchange Mailbox Checker app first to ensure the mailboxes exist.




Gui,Add, Text, x592 y-1 w140 h20 +Center, EXCHANGE PULLER
Gui,Add, Text, x12 y12 w130 h30 , 4-Letter_Code*:
Gui,Add, Edit, x152 y12 w100 h20 vmatter, XXXX
Gui,Add, Text, x12 y52 w130 h30 , Technician_Last_Name*:
Gui,Add, Edit, x152 y52 w200 h20 vTechnician, 
Gui,Add, Text, x12 y142 w130 h30 , Select Domain*:
Gui,Add, DropDownList, x152 y142 w150 h90 vdomain gMRSChange, ABC_DOMAIN|XYZ_DOMAIN
Gui,Add, Text, x12 y179 w130 h30 , Select MRSServer*:
Gui,Add, ComboBox, x152 y179 w250 h300 vmrsserver_selection, 
Gui,Add, Text, x442 y42 w350 h30 , Add Custodians and Alias Names (Note: ONE custodian per line)`nFormat: CustLast_CustFirst*alias
Gui,Add, Edit, x442 y82 w350 h120 valias_list, Doe_John*jdoe
Gui,Add, Text, x12 y219 w120 h20 , Export_UNC_Folder*:
Gui,Add, ComboBox, x152 y219 w630 h10 vExportdir, 
Gui,Add, CheckBox, x12 y299 w130 h30 gChkChange vCB1, Enable Date Range
Gui,Add, Text, x12 y339 w60 h20 , Start Date:
Gui,Add, Button, x12 y369 w60 h20 gSelect_Begin_Date vselectstartbutton, Select
GuiControl, Disable, selectstartbutton
Gui,Add, Text, x82 y339 w90 h20 vstartdate, % startdate
GuiControl, Disable, startdate
Gui,Add, Text, x222 y339 w60 h20 , End Date:
Gui,Add, Text, x292 y339 w90 h20 venddate, % enddate
GuiControl, Disable, enddate
Gui,Add, Button, x222 y369 w60 h20 gSelect_End_Date vselectendbutton, Select
GuiControl, Disable, selectendbutton
Gui,Add, Button, x632 y329 w170 h60 gGO, Create Batch File
Gui,Show, x2229 y622 h405 w820,%AppTitle%

MRSChange:
guicontrolget, domain
If (domain = "ABC_DOMAIN") 
    {
    GuiControl,, Edit3, |  ;clears the list
	GuiControl, , Edit3, SERVER01.us.ABC.net|SERVER02.us.ABC.net|SERVER03.us.ABC.net|SERVER04.us.ABC.net|SERVER05.us.ABC.net|SERVER06.us.ABC.net|SERVER07.us.ABC.net|SERVER08.us.ABC.net|SERVER09.us.ABC.net|SERVER10.us.ABC.net|SERVER11.us.ABC.net|SERVER12.us.ABC.net|SERVER13.us.ABC.net|SERVER14.us.ABC.net|SERVER15.us.ABC.net|SERVER16.us.ABC.net|SERVER17.us.ABC.net||SERVER18.us.ABC.net  ;mrssserver(s)
    GuiControl,, Edit5, |  ;clears the list
    GuiControl, , Edit5, \\SERVER2.us.ABC.net\D$\_COMPANY_TEMP\||
   } 
else If (domain = "XYZ_DOMAIN") 
   {
    GuiControl,, Edit3, |  ;clears the list
	GuiControl, , Edit3, SERVERUSA.XYZ.com|| ;mrssserver(s)
    GuiControl,, Edit5, |  ;clears the list
    GuiControl, , Edit5, \\XYZfs1.XYZ.com\_COMPANY_TEMP\||
    
	} 
return

ChkChange:

  GuiControlGet, CheckBoxState,, CB1
  If (CheckBoxState = 1)
     { 
       GuiControl, Enable, startdate
       GuiControl, Enable, selectstartbutton
       GuiControl, Enable, enddate
       GuiControl, Enable, selectendbutton
     } 
  Else 
     {
       GuiControl, Disable, startdate
       GuiControl, Disable, selectstartbutton
       GuiControl, Disable, enddate
       GuiControl, Disable, selectendbutton
     }
Return

Select_Begin_Date:
{
   Gui, 2: Destroy
   Gui, 2: +AlwaysOnTop
   Gui, 2: Add, MonthCal,  vmycalendar1
   Gui, 2: Add, Button, x+5 hp gCalendar1, Go
   Gui, 2:Show
   Return

   Calendar1: 
   Gui, 2: Submit
   ;msgbox,%mycalendar1% ;YYYYMMDD
   StartDateYYYYMMDD = %mycalendar1%
   FormatTime, mycalendar1, %mycalendar1%, MM/dd/yyyy
   ;msgbox,%mycalendar1% ;MM/DD/YYYY
   GuiControl, 1:,startdate,%mycalendar1%
   startdate = %mycalendar1%
   return
}

Select_End_Date:
{
   Gui, 3: Destroy
   Gui, 3: +AlwaysOnTop
   Gui, 3: Add, MonthCal,  vmycalendar2
   Gui, 3: Add, Button, x+5 hp gCalendar2, Go
   Gui, 3:Show
   Return

   Calendar2: 
   Gui, 3: Submit
   ;msgbox,%mycalendar2% ;YYYYMMDD
   EndDateYYYYMMDD = %mycalendar2% ;YYYYMMDD used for filename
   EndDateYYYYMMDD2 = %mycalendar2% ;YYYYMMDD used to add days
   FormatTime, mycalendar2, %mycalendar2%, MM/dd/yyyy
   GuiControl, 1:,enddate,%mycalendar2% ;displays selected date in GUI as MM/DD/YYYY
   enddate = %mycalendar2% ;end date shown in audit log as MM/DD/YYYY


   EndDateYYYYMMDD2 += 1, Days ;adds one day to date
   FormatTime, enddate_plus1, %EndDateYYYYMMDD2%, MM/dd/yyyy
   return
}

Go:
Gui, Submit,NoHide
GuiControlGet, CheckBoxState,, CB1
emptyfields := [matter,Technician,domain,alias_list,mrsserver_selection,Exportdir]
for i,a in emptyfields
{
    If !a
    {
		MsgBox, 48, Warning, You are missing required fields ;show error message
        return
    }
}
  If (CheckBoxState = 1)
     {
  emptyfields := [startdate,enddate]
for i,a in emptyfields
{
    If !a
    {
		MsgBox, 48, Warning, You are missing required fields (see date fields) ;show error message
        return
    }
} 
}


Gui, Destroy

;;;;;;;;;;;;;;EXPORT OPTIONS;;;;;;;;;;;;;;;;;;;
If (domain = "ABC_DOMAIN")
{
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------
; O P T I O N S
MRSServer = %mrsserver_selection% ;collection server
ExportServer = SERVER2.us.ABC.net  ;export server location and will be placed in following path \\SERVER2.us.ABC.net\C$\...
Log = %A_Desktop%\%matter%-ExchangePullLog-%A_Now%
PS_Mode = 2 ; 1 = Command Prompt - 2 = Batchfile
Delete_BAT = 0 ; 0 = Keep batchfile after it ran - 1 = Delete batchfile after it ran and the Command Prompt is closed

;---------------------------------------------------------------------------------------------------------------------------------------------------------------------
}

If (domain = "XYZ_DOMAIN")
{
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------
; O P T I O N S
MRSServer = %mrsserver_selection% ;collection server
ExportServer = %A_ComputerName% ;export server location
Log = %A_Desktop%\%matter%-ExchangePullLog-%A_Now%
PS_Mode = 2 ; 1 = Command Prompt - 2 = Batchfile
Delete_BAT = 0 ; 0 = Keep batchfile after it ran - 1 = Delete batchfile after it ran and the Command Prompt is closed
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------
}


  If (CheckBoxState = 1)
     {
   daterangeselection = Enabled
      }
  If (CheckBoxState = 0)
     {
   daterangeselection = disabled
      }

;;;;;;;;;;;;;;;;System Log
FileAppend,%AppTitle%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Start Time (Local):%A_Now%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Start Time (UTC):%A_NowUTC%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,+++++++++++++++++++++++++++++++++++++++`n, %Log%.txt ; Write to a fresh new output file
FileAppend,COLLECTION INFO (Inputted/Selected by Technician):`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Matter Name: %Matter%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Technician Name: %Technician%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Domain Name: %domain%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,MRS Server: %mrsserver_selection%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Export Directory: %Exportdir%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Date Range: %daterangeselection%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Start Date: %startdate%`n, %Log%.txt ; Write to a fresh new output file
FileAppend,End Date: %enddate%`n, %Log%.txt ; Write to a fresh new output file
  If (CheckBoxState = 1)
     {

}
FileAppend,+++++++++++++++++++++++++++++++++++++++`n, %Log%.txt ; Write to a fresh new output file
FileAppend,Command(s) Run:`n, %Log%.txt ; Write to a fresh new output file
;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;PARSE CUSTODIAN NAMES AND ALIAS
Loop, Parse, alias_list, `r`n
{

	If (A_LoopField = "")
        continue    ; Skip this row its blank
    else
        Loop, Parse, A_LoopField, *
        {
            if (A_Index = 1)
                fullname := A_LoopField
            else
                aliasname := A_LoopField
         } 
 
  If (CheckBoxState = 1) ;aka date range enabled
   { 
command = start cmd.exe /k C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -noexit -command . 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; New-MailboxExportRequest -mailbox %aliasname% -ContentFilter {((Received -le '%enddate_plus1%') -and (Received -ge '%startdate%')) -or ((Sent -le '%enddate_plus1%') -and (Sent -ge '%startdate%'))} -BadItemLimit 25 -MRSServer %MRSServer% -FilePath %Exportdir%%matter%-%fullname%-[%aliasname%]-ActiveExch-%domain%-FILTERED-[S-%StartDateYYYYMMDD%]-[E-%EndDateYYYYMMDD%]-[Pulled-%TimeString%].pst
    } 
  
  Else ;date range disabled
     {
   command = start cmd.exe /k C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -noexit -command . 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; New-MailboxExportRequest -mailbox %aliasname% -BadItemLimit 25 -MRSServer %MRSServer% -FilePath %Exportdir%%matter%-%fullname%-[%aliasname%]-ActiveExch-%domain%-FULL_PULL-[Pulled-%TimeString%].pst
     }
    
    	FileAppend,%command%`n,%A_Desktop%\%matter%-ExchangeMailboxPuller-%A_Now%.bat
		FileAppend,%command%`n,%Log%.txt 
} ;end of loop 


FileAppend,+++++++++++++++++++++++++++++++++++++++`n, %Log%.txt ; Write to a fresh new output file
FileAppend,END OF LOG`n, %Log%.txt ; Write to a fresh new output file

MsgBox, 4144, %AppTitle%, WARNING:`nCheck the export location to confirm there is ample space for the PST export(s) BEFORE running the batch file!`n`n%Exportdir%

MsgBox, 262208,%AppTitle%, Batch File Creation Complete`n`nOn the desktop`, you will find a batch file called:`nExchangeMailboxPuller-%A_Now%.bat`n`nLog File: %Log%.txt`n`nRun that batch on the Exchange server to pull the associated mailboxes. 

exitapp


   ;-ge (greater than or equal to)
   ;-le (less than or equal to)


GuiClose:
ExitApp
♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
coder_chick
Posts: 185
Joined: 05 Nov 2015, 10:43

Re: Script works on Win10 but not Win7 (please help a girl out!!)

21 May 2019, 23:54

No one knows? Where are all the AHK gods?!
♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
Xtra
Posts: 1415
Joined: 02 Oct 2015, 12:15

Re: Script works on Win10 but not Win7 (please help a girl out!!)

22 May 2019, 00:56

Using x2229 when showing the gui is it even on the monitor on win7 etc?

HTH
User avatar
coder_chick
Posts: 185
Joined: 05 Nov 2015, 10:43

Re: Script works on Win10 but not Win7 (please help a girl out!!)

22 May 2019, 09:19

You sir, are correct. I can't believe I missed that. I also don't even know why I have that in there.

This did the trick:

Code: Select all

Gui,Show,h405 w820,%AppTitle%
♥ ❤ ❥ coder_chick ♥ ❤ ❥

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 227 guests