Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:20:14+00:00 2026-06-18T04:20:14+00:00

i have a script which created a small windows gui form with buttons depending

  • 0

i have a script which created a small windows gui form with buttons depending on the scenarios;

-> on clicking, these buttons open respective files on remote file shares;following is the code;

$run.Add_Click({Invoke-Expression "Powershell \\Fileshare\$Random_File.Doc"}.GetNewClosure())

-> my issue is eventhough after the click the file opens ; the form still hangs arround in the back ground; I want to know how to close it(and even better if i can close whole powershell too) ; i tried to embed “;exit” inside invoke but it gave errors , is there any other way to do it?

Please ask me if any questions or clarifications required.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:20:15+00:00Added an answer on June 18, 2026 at 4:20 am

    I suspect Invoke-Item \\fileshare\$file will work much better than running new PowerShell for any document you want to open.

    To close the form you can add $this.Parent (?).Close()
    or just reference $form variable – that also should work:

    $form = New-Object System.Windows.Forms.Form
    $run = New-Object System.Windows.Forms.Button -Property @{
        Location = New-Object System.Drawing.Point -Property @{
            X = 0
            Y = 0
        }
        Text = 'Run'
    }
    $run.Add_Click({
        Invoke-Item C:\Windows
        $form.Close()
    })
    $form.Controls.Add($run)
    $form.ShowDialog()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a jQuery menu which will open when clicking on a small
Aloha everyone, I have created a small bash shell script which I wanted to
I have a script which validates each stage of a form and adds a
I have a small script, which is called daily by crontab using the following
I have created a simple vf page and placed and small jQuery script in
I have written a small bash script which clears the logs (say that script
I have a script which creates a user-defined object like this: obj = new
I have an SQL script which creates a scheduled event: CREATE EVENT Daily_1200PM SCHEDULE
I have a PHP script which creates and listens on a port for connections
I'm trying to write a basic script which creates a UI. I have reduced

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.