Hello,
I am new to Power Shell , and I have a question regarding running power shell script from power shell ISE versus running it from a my directory such as I double click on my power shell script file.
When I ran power shell script from ISE, it gave me my desired result such as a pop up window as I instructed it on my script.
However when I double clicked my power shell script from my directory, the window was appeared very fast in a split second, and gone. I wonder where does it go ? and why it does not give me a window like I was sunning it from Power Shell ISE.
I wonder what do I need to do and how to get the same behavior as I run my script from my directory. So please help me if you could.
Many Thanks,
Attached is my simple script
using System.Text;
public class Win32 {
[DllImport(“user32.dll”, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
[DllImport(“user32.dll”, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
}
public struct RECT
{
public int Left; // x position of upper-left corner
public int Top; // y position of upper-left corner
public int Right; // x position of lower-right corner
public int Bottom; // y position of lower-right corner
}
"@
#Win32::GetWindowRect
$Handle = (Get-Process -Id $Pid).MainWindowHandle
$Rectangle = New-Object RECT
Win32::MoveWindow($Handle, 200, 150, 300, 400, $true)