I have this PowerShell script I been working on. I have done lots of debugging and all the functions within it are working fine. I plan to add more options as needed. My end goal is to make it an available program that could run alongside other programs I have open. Would like it to be able to sit in the taskbar, where the end user just has to click it to open the window and run it like any other PowerShell script. Any thoughts on where I could start? I found an exe called ps2exe but it doesn’t seem to allow the script to be launched by clicking on it. It just something I been working in and would like to see it run as another program. Any thoughts would be appreciated.
If you want a .exe then there are various techniques to create one. This article has a good summary:
If you just want a shortcut on the task bar. Create a shortcut that points to something like:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NoExit -File E:\Temp\runme.ps1
Change the icon to something fancy and no one will be any the wiser
You may have to experiment with the switches to get the exact result you’re after. You can view them with:
Thanks for the update! A old coworker had mentioned about wrapping it into an exe, so any end user could use it without having to actually opening PowerShell and all. I’ll take a look.
I think you missed the important lesson. You don’t actually need an exe to be able to have a program people can run. As a matter of fact many times converting it to an exe is counterproductive because it gets flagged by antivirus or Windows defender
Hey there, that is a good point. Yeah I’m mainly looking to learn how to make it into a program people can run after I do the dirty work. Been around PowerShell for years and trying to make something with it.
It depends pretty much on what you want to do with the script but the simplest way for people to run it would be to make a shortcut on the desktop or in the start menu they can click at.
Olaf! yeah that is what I would like to do with it, allow it to be clicked on from either of those places and have the script load. I just haven’t done this before, so learning something new. I’m going along with the comments from Matt too.
In case you wonder how to call the PowerShell console and run a script you simply run …
I can really say I have hardly ever run that simple command, I’ll have to pay more attention to it. Usually I’m reading the errors in my scripts and trying to drill down and debug from there.
What I do (many times) is create a MS shortcut that links to the starting script (ie. Home.ps1). This way, you can alter the scripts as many times as you want without having to re-compile the exe. Obv not as nice for distribution, but if it is just for someone to click and use then this work. You can even change the icon image.
Just make sure you point the shortcut to your script and “Start in:” should be either PSv5 or PSv5 directory depending on what you are using.