I am working on a PowerShell script with a GUI with 3 files:
window1.ps1- input into variable and startsstart.vbsstart.vbs- startswindow2.ps1window2.ps1- displays the value entered in window1
In window1, I enter value1 into textbox1 and click the button.
By clicking it, value1 should be stored into a global variable, so that window2 can pop up (via VBS) and use value1.
code for button in window1:
$button_OnClick=
{
$global:value1 = $textBox1.Text
start-process .\start.vbs
}
start.vbs:
Set objShell = CreateObject("Wscript.Shell")
objShell.run("powershell.exe -nologo -file .\window2.ps1"), 0, True
So far so good. From what I understand, value1 is a global variable and can be used in window2.ps1.
So window2 is an empty window with only a text that should display value1.
$label1.Text = "$value1"
But for some reason, the variable is empty and window2 is empty.
What am I missing? I'm still learning PowerShell and I might be missing a detail.
note: I know the way I open up
window2via .vbs is weird. But that way, the GUI opens up without any PowerShell window in the background.

