Since the PowerShell cannot accept keyboard input it works out ok and the second script does not get run until the first finishes since the window is not able to accept the text. The issue is that once the first script finishes and the text for the second script is sent and the second script starts I then do a check to see if another routine should run which starts another program outside the PowerShell. This routine should not run until the second script completes.
I am not sure how to make Macro Scheduler wait for the second script to complete before calling the last routine. Is there a way to determine in a PowerShell or command line whether or not a command has completed?
Below is the code as it currently exists:
Code: Select all
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
Dialog>InstallSegment
object InstallSegment: TForm
Left = 285
Top = 115
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Segment Information'
ClientHeight = 185
ClientWidth = 278
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 120
TextHeight = 16
object LabelSegmentName: TLabel
Left = 8
Top = 16
Width = 94
Height = 16
Caption = 'Segment Name'
end
object LabelEnvironment: TLabel
Left = 8
Top = 56
Width = 74
Height = 16
Caption = 'Environment'
end
object TextSegment: TEdit
Left = 112
Top = 9
Width = 73
Height = 24
TabOrder = 0
TextHint = 'ie... AAAA, BBBB'
end
object ButtonInstall: tMSButton
Left = 96
Top = 144
Width = 75
Height = 25
Caption = 'Install'
TabOrder = 1
DoBrowse = False
BrowseStyle = fbOpen
end
object ComboBoxEnvironmentType: tMSComboBox
Left = 111
Top = 56
Width = 145
Height = 24
TabOrder = 2
Text = 'Select one'
Items.Strings = (
'Local'
'Development'
'Test'
'Demo'
'Production')
ListText = 'Local'#13#10'Development'#13#10'Test'#13#10'Demo'#13#10'Production'#13#10
end
object ButtonQuit: tMSButton
Left = 184
Top = 144
Width = 75
Height = 25
Caption = 'Quit'
TabOrder = 3
DoBrowse = False
BrowseStyle = fbOpen
end
object CheckBoxInstallReports: TCheckBox
Left = 113
Top = 103
Width = 136
Height = 17
Caption = 'Install Reports'
Checked = True
State = cbChecked
TabOrder = 12
end
end
EndDialog>InstallSegment
AddDialogHandler>InstallSegment,ButtonInstall,OnClick,DoInstall
AddDialogHandler>InstallSegment,ButtonQuit,OnClick,DoQuit
Show>InstallSegment,
// User quits install
SRT>DoQuit
CloseDialog>InstallSegment
END>DoQuit
// User begins install
SRT>DoInstall
GetDialogProperty>InstallSegment,TextSegment,Text,varSegment
GetDialogProperty>InstallSegment,ComboBoxEnvironmentType,Text,varEnvironment
GetDialogProperty>InstallSegment,CheckBoxInstallReports,Checked,varInstallReports
If>{(%varEnvironment% = "Local")}
StringReplace>varEnvironment,Local,local,varEnvironment
ENDIF
If>{(%varEnvironment% = "Development")}
StringReplace>varEnvironment,Development,dev,varEnvironment
ENDIF
If>{(%varEnvironment% = "Test")}
StringReplace>varEnvironment,Test,test,varEnvironment
ENDIF
If>{(%varEnvironment% = "Demo")}
StringReplace>varEnvironment,Demo,demo,varEnvironment
ENDIF
If>{(%varEnvironment% = "Production")}
StringReplace>varEnvironment,Production,,varEnvironment
ENDIF
Let>varProtocol=https://
LowerCase>%varSegment%,varSegmentLowerCase
Let>varUrl=%varProtocol%%varSegmentLowerCase%%varEnvironment%.mysite.com
Let>RP_WINDOWMODE=1
Let>RP_WIN64PROCESS=1
RunProgram>C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "
Wait 3
SetFocus>Administrator: C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
SendText>cd "C:\Program Files (x86)\XXXX\XXXXX"
Press Enter
Send>.\i
Press Tab
Wait>1
Press Enter
Wait>2
Send>cd ..
Press Enter
Send>cd %varSegment%
Press Enter
Wait>2
// This should not occur until the previous script has completed
// however since the PowerShell cannot accept the command it is
// queued until the previous command completes.
Send>.\install_%varSegment%
Press Tab
Press Space
Send> %varUrl%
Wait>2
Press Enter
// This should not occur until the previous script has completed
// but I need to figure out how to tell Macro Scheduler to wait
// for the previous script to complete first.
// Install reports if the box is checked
If>{(%varInstallReports% = "True")}
GoSub>InstallReports
ENDIF
END>DoInstall
// Should not run until all scripts in DoInstall have completed
SRT>InstallReports
// Call external program to install reports
END>InstallReports