# Powershell Studio 2012 and Process time

**URL:** <https://forums.powershell.org/t/powershell-studio-2012-and-process-time/13703>\
**Category:** PowerShell Help\
**Created:** [January 24, 2020, 8:58am UTC](https://forums.powershell.org/t/powershell-studio-2012-and-process-time/13703 "2020-01-24T08:58:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikarin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/mikarin/32/141_2.png) [@mikarin](https://forums.powershell.org/u/mikarin)\
**Post date:** [January 24, 2020, 8:58am UTC](https://forums.powershell.org/t/powershell-studio-2012-and-process-time/13703/1 "2020-01-24T08:58:52Z")

</div>

Hello

I made a small script and designed it on Sapien visual studio 2012. The issue that cmdlets themselves are working fine but when i add button and assigning them, Powershell Management Shell is not completing basic cmdlets like  
\*Merge-splogfile | bla bla

Stopping while creating a file

Any idea how to perform proper way or suggestion?

Thanks

&nbsp;

&nbsp;

[pre]

#------------------------------------------------------------------------

# Source File Information (DO NOT MODIFY)

# Source ID: 9e2a3b4e-e308-4a36-a5db-69fef85780c2

# Source File: correlationID.pff

#------------------------------------------------------------------------  
#region File Recovery Data (DO NOT MODIFY)  
\<#RecoveryData:  
PRQAAB+LCAAAAAAABADVWG1v2jAQ/j5p/yHLZwaElAITRGrTdqrWF1RY1w9IlQmX1qtjI8dpm2k/  
fnZeaF6gDYyuq5AQOZ/9PD4/8R3XvwCH3QMPD5BA1scPmtY/5/gGU0SOMIEz5IHlMM6BIIEZPT6o  
z1233yj5RDPV0yVwXzpaRr3Vb2QN8drTn+AITYRzGOij0Bfg1X9gOmMPfv2IcS/+rmnLhmpastRg  
p95Un5pmB0QEHAYUAsERqWnDYEqw8w3CMbsDOph2OqjttHeNnrkDzW5P16gkO9BduZ6ha84tJjMu  
/XSbUcEZ8fWIpiQ65GwOXITJBJtgoGKEf4Futbo7Na21a/QbqdOKSSowuhVhveg7hkehW2qfZdfD  
e4md+J0wNEvWvFa/+41oNHV9Ob77gRCMvnqEpxHM+Ryo0sBzoS7H4oQ5kdh0q9utaUanXQrJqljn  
UStMi0+026tp7U4F9zGaHtMZPOqWWcU7OlPFRqtI57sPl9gPEBmJkMA+cu5sRhjXrTEPls7PSkNq  
1LkrxuA6shZU0ohl8p+K5vTw4uvhpoppKcU0W2sqJoKsLJeW0VpbL1UYxXqJuHz6p2KJIN+hUuxs  
YtpUMUbbkNd5d03F5KBf86Ipp45VwlmX0vb0k0N+hzpKq5i/uXTWVlAK+priaVYWzxpstqebFPRF  
yeQf9nwfPHm84Ke+iSW0ErmcIopuwJOr1fcCwbzonJ5kY1SVjWlMXbPb3kUzc3cHTFmILJCKyJ4v  
y2SCp1sQ5zMo8f62gPHb/jJJXqrJKXY485kr6meH48kRlyfywPjd5F6tbjZNozdJ4joj5EVyW39X  
N6Oav04qEVd/gd6MrwKvSJOjB0xvNmHaNN2223ENY9ZuIhNtyDTGr0b2yiNvFtKr05OKEcVcXi6M  
hyPg99iBjVS7ndgWmVTbgEzA8GZhVuDVaCabkhlC7uztgpynsYT64jFNMf2hzHIyo/B0Z1+BgiSY  
yZGxw6IXEqewpdbEeOwkTZGca94q8xh2wRc2hyiFqWqwZFt424Evc106nll71cBQ1myqlWB9VlVm  
+rAYvgjoaLyniojk19NE9gB8dAuEpN0d9f+mZEwzeT5a/RE4AceynmiklvyEUicpUke5m5QWJ7PA  
ESXngr3oXzyoZdYD8B2O5/kgN5ZabebNEQ2zMS9abDYPOb65zR1M2XZMBXCKSIHgcvPSNlxSPa0c  
ksy8pzor4eplK69cy66R0b5UQrZd+AcBqfxdPRQAAA==#\>  
#endregion  
#========================================================================

# Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.20

# Generated On: 1/24/2020 3:04 PM

# Generated By: A701026

#========================================================================  
#----------------------------------------------  
#region Application Functions  
#----------------------------------------------

function OnApplicationLoad {  
#Note: This function is not called in Projects  
#Note: This function runs before the form is created  
#Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path  
#Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList)  
#Important: Form controls cannot be accessed in this function  
#TODO: Add snapins and custom code to validate the application load

return $true #return true for success or false for failure  
}

function OnApplicationExit {  
#Note: This function is not called in Projects  
#Note: This function runs after the form is closed  
#TODO: Add custom code to clean up and unload snapins when the application exits

$script:ExitCode = 0 #Set the exit code for the Packager  
}

#endregion Application Functions

#----------------------------------------------

# Generated Form Function

#----------------------------------------------  
function Call-correlationID\_pff {

#----------------------------------------------  
#region Import the Assemblies  
#----------------------------------------------  
[void][reflection.assembly]::Load(“mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”)  
[void][reflection.assembly]::Load(“System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”)  
[void][reflection.assembly]::Load(“System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”)  
[void][reflection.assembly]::Load(“System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”)  
[void][reflection.assembly]::Load(“System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”)  
[void][reflection.assembly]::Load(“System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”)  
[void][reflection.assembly]::Load(“System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”)  
[void][reflection.assembly]::Load(“System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”)  
[void][reflection.assembly]::Load(“System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”)  
#endregion Import Assemblies

#----------------------------------------------  
#region Generated Form Objects  
#----------------------------------------------  
[System.Windows.Forms.Application]::EnableVisualStyles()  
$form1 = New-Object ‘System.Windows.Forms.Form’  
$buttonOpenFile = New-Object ‘System.Windows.Forms.Button’  
$buttonMERGE = New-Object ‘System.Windows.Forms.Button’  
$buttonCorrelationID = New-Object ‘System.Windows.Forms.Button’  
$buttonFileName = New-Object ‘System.Windows.Forms.Button’  
$InitialFormWindowState = New-Object ‘System.Windows.Forms.FormWindowState’  
#endregion Generated Form Objects

#----------------------------------------------

# User Generated Script

#----------------------------------------------

$form1\_Load={  
#TODO: Initialize Form Controls here

}

$buttonFileName\_Click={  
#TODO: Place custom script here

[void][Reflection.Assembly]::LoadWithPartialName(‘Microsoft.VisualBasic’)

$title = ‘FileName’  
$msg = ‘Enter your Filename:’

$text = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)

}

$buttonCorrelationID\_Click={  
#TODO: Place custom script here

[void][Reflection.Assembly]::LoadWithPartialName(‘Microsoft.VisualBasic’)

$title2 = ‘CorrelationID’  
$msg2 = ‘Write CorrelationID:’

$corrID = [Microsoft.VisualBasic.Interaction]::InputBox($msg2, $title2)

}

$buttonMerge\_Click={  
#TODO: Place custom script here  
Merge-SPLogFile -Path C:\users$env:USERNAME\Desktop\script$text.txt -Correlation $corrID  
}

$buttonOpenFileAstxt\_Click={  
#TODO: Place custom script here  
Invoke-Item C:\users$env:USERNAME\Desktop\script$text.txt  
}

$buttonOpenFile\_Click={  
#TODO: Place custom script here

}

# –End User Generated Script–

#----------------------------------------------  
#region Generated Events  
#----------------------------------------------

$Form\_StateCorrection\_Load=  
{  
#Correct the initial state of the form to prevent the .Net maximized form issue  
$form1.WindowState = $InitialFormWindowState  
}

$Form\_Cleanup\_FormClosed=  
{  
#Remove all event handlers from the controls  
try  
{  
$buttonOpenFile.remove\_Click($buttonOpenFile\_Click)  
$buttonMERGE.remove\_Click($buttonMERGE\_Click)  
$buttonCorrelationID.remove\_Click($buttonCorrelationID\_Click)  
$buttonFileName.remove\_Click($buttonFileName\_Click)  
$form1.remove\_Load($form1\_Load)  
$form1.remove\_Load($Form\_StateCorrection\_Load)  
$form1.remove\_FormClosed($Form\_Cleanup\_FormClosed)  
}  
catch [Exception]  
{ }  
}  
#endregion Generated Events

#----------------------------------------------  
#region Generated Form Code  
#----------------------------------------------

# 

# form1

# 

$form1.Controls.Add($buttonOpenFile)  
$form1.Controls.Add($buttonMERGE)  
$form1.Controls.Add($buttonCorrelationID)  
$form1.Controls.Add($buttonFileName)  
$form1.ClientSize = ‘284, 261’  
$form1.Name = “form1”  
$form1.Text = “Form”  
$form1.add\_Load($form1\_Load)

# 

# buttonOpenFile

# 

$buttonOpenFile.Location = ‘88, 175’  
$buttonOpenFile.Name = “buttonOpenFile”  
$buttonOpenFile.Size = ‘89, 57’  
$buttonOpenFile.TabIndex = 3  
$buttonOpenFile.Text = “Open File”  
$buttonOpenFile.UseVisualStyleBackColor = $True  
$buttonOpenFile.add\_Click($buttonOpenFile\_Click)

# 

# buttonMERGE

# 

$buttonMERGE.Location = ‘28, 102’  
$buttonMERGE.Name = “buttonMERGE”  
$buttonMERGE.Size = ‘212, 57’  
$buttonMERGE.TabIndex = 2  
$buttonMERGE.Text = “MERGE!”  
$buttonMERGE.UseVisualStyleBackColor = $True  
$buttonMERGE.add\_Click($buttonMERGE\_Click)

# 

# buttonCorrelationID

# 

$buttonCorrelationID.Location = ‘151, 28’  
$buttonCorrelationID.Name = “buttonCorrelationID”  
$buttonCorrelationID.Size = ‘89, 57’  
$buttonCorrelationID.TabIndex = 1  
$buttonCorrelationID.Text = “CorrelationID”  
$buttonCorrelationID.UseVisualStyleBackColor = $True  
$buttonCorrelationID.add\_Click($buttonCorrelationID\_Click)

# 

# buttonFileName

# 

$buttonFileName.Location = ‘28, 28’  
$buttonFileName.Name = “buttonFileName”  
$buttonFileName.Size = ‘89, 57’  
$buttonFileName.TabIndex = 0  
$buttonFileName.Text = “FileName”  
$buttonFileName.UseVisualStyleBackColor = $True  
$buttonFileName.add\_Click($buttonFileName\_Click)  
#endregion Generated Form Code

#----------------------------------------------

#Save the initial state of the form  
$InitialFormWindowState = $form1.WindowState  
#Init the OnLoad event to correct the initial state of the form  
$form1.add\_Load($Form\_StateCorrection\_Load)  
#Clean up the control events  
$form1.add\_FormClosed($Form\_Cleanup\_FormClosed)  
#Show the Form  
return $form1.ShowDialog()

} #End Function

#Call OnApplicationLoad to initialize  
if((OnApplicationLoad) -eq $true)  
{  
#Call the form  
Call-correlationID\_pff | Out-Null  
#Perform cleanup  
OnApplicationExit  
} [/pre]

&nbsp;

``

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:30pm UTC](https://forums.powershell.org/t/powershell-studio-2012-and-process-time/13703/2 "2024-05-16T20:30:45Z")

</div>


