Scripte Windows Download Form

  



Scripte Windows Download Form

Download Tron Script - Run multiple Windows scripts at the same time with the help of this collection of system tweakers that makes the entire process automatic. Lao Script application and font downloads. The applications and fonts listed below and available for download are provided freely and may be used for private, commercial or government purposes without restriction, but may not be distributed under any other name or sold.

-->

The Windows SDK Components for Windows Installer Developers contains VBScript files that show you how the Windows Installer automation interface is used to modify Windows Installer packages.

Scripte windows download form free

The script samples identified in this topic are not supported by Microsoft Corporation, and they are provided only as a potentially useful reference. Running these samples requires the Windows Script Host. For more information about Windows Script Host, see the Windows Script Host section of the Microsoft Windows Software Development Kit (SDK).

Sample Script FileDescription
WiLstPrd.vbsList Products, Properties, Features, and Components
WiImport.vbsImport Files
WiExport.vbsExport Files
WiSubStg.vbsManage Substorages
WiStream.vbsManage Binary Streams
WiMerge.vbsMerge Two Databases
WiGenXfm.vbsGenerate a Transform
WiUseXfm.vbsApply a Transform
WiLstXfm.vbsView a Transform (CSCRIPT only)
WiDiffDb.vbsView Differences Between Two Databases (CSCRIPT only)
WiLstScr.vbsView Installer Script (CSCRIPT only)
WiSumInf.vbsManage Summary Information
WiPolicy.vbsManage Policy Settings
WiLangId.vbsManage Language and Codepage
WiToAnsi.vbsCopy a Unicode File to an Ansi File
WiFilVer.vbsManage File Sizes and Versions
WiMakCab.vbsGenerate File Cabinet
WiRunSQL.vbsExecute SQL Statements
WiTextIn.vbsCopy ANSI File Into a Database Field
WiCompon.vbsList Components
WiFeatur.vbsList Features
WiDialog.vbsPreview User Interface

All these scripts display a help screen that describes their command line arguments. To display the help screen in Windows double-click the file. To display the help screen from a command line enter a ? as the first argument, or enter fewer arguments than required. Scripts return a value of 0 for success, 1 if help is invoked, and 2 if in case of failure.

These samples require Windows Script Host to run. Windows Script Host is actually two hosts:

  • CScript.exe is the version that enables you to run scripts from the command prompt, and provides command-line switches for setting script properties.
  • WScript.exe is the version of Windows Script Host that enables you to run scripts from Windows. For more information, see the Windows Script Host section in the Windows SDK.

The Makecab.exe utility is included with the patching samples in the Windows SDK Components for Windows Installer Developers.

For information about WMI, see Using Windows Installer with WMI.

It’s weekend project time again and today you will learn how to build a lightweight system tray PowerShell form menu where you can quickly and easily launch your most coveted PowerShell scripts. You can see below the end result.

In this article, you’ll learn how to build your own PowerShell menu GUI by breaking the process down step-by-step.

Scripte Windows Download Form Free

Environment and Knowledge Requirements

Before you dive in, please be sure you meet the following minimum requirements:

  • Windows 7 or later
  • Windows PowerShell 3 or later – The latest version of .NET Core 3.0 with PowerShell 7 preview may work on Windows due to recent added support for WPF and WinForm, but is untested.
  • .NET Framework 4.5 or later
  • A familiarity with Windows Forms (WinForms) You can, however, due this with WPF too though.

For this project, the good news is that you won’t really need to rely on Visual Studio, PoshGUI, or any other UI development tool as the primary components that this project will rely on the following:

  • NotifyIcon – This will represent our customizable system tray icon for the user to interact with.
  • ContextMenu – Container for when the user right-clicks on the tray icon.
  • MenuItem – Individual objects for each option within the right-click menu.

Open up your favorite PowerShell script editor and let’s get started!

For this project you are going to build three functions: two functions to show/hide the console to provide a cleaner user experience and one to add items to your systray menu. These functions will serve as a foundation for later use to make your life much easier as you will learn a bit later in this article.

Show/Hide Console Window

Unless hidden, when you launch a PowerShell script, the familiar PowerShell console will come up. Since the menu items in the PowerShell form you’ll create will launch scripts, you should ensure the console doesn’t up. You just want it to execute.

When a script is executed, you can toggle the PowerShell console window showing or not using a little .NET.

First add the Window .NET type into the current session. To do this, you’ll use some C# as you’ll see below. The two methods you need to load into context are GetConsoleWindow and ShowWindow. By loading these DLLs into memory you are exposing certain parts of the API, this allows you to use them in the context of your PowerShell script:

Create two functions using the loaded above using the GetConsoleWindow() and ShowWindow() method as shown below.

With these two functions you now have created a way in which you can show or hide the console window at will.

Note: If you’d like to see output from the scripts executed via the menu, you can use PowerShell transcripts or other text-based logging features. This allows you to maintain control versus only running the PowerShell session with the WindowStyle parameter to hide.

Now begin building script code by calling Start-HideConsole. When the PowerShell form menu-driven script executes, this will ensure the PowerShell console window doesn’t come up.

Create Menu Options

Now it’s time to create the menu options. Ensuring you can easily create new options later on, create another function this time called New-MenuItem. When you call this function, it will create a new MenuItem .NET object which you can then add to the menu later.

Each menu option will launch another script or exit the launcher. To accommodate for this functionality, the New-MenuItem function has three parameters:

  • Text – The label the user will click on
  • MyScriptPath – The path to the PowerShell script to execute
  • ExitOnly – The option to exit the launcher.

Add the below function snippet to the menu script.

Continuing on building the New-MenuItem function, create a MenuItem object by assigning it to a variable.

Next, assign the text label to the menu item.

Scripte windows download format

Now add a custom property to the MenuItem called MyScriptPath. This path will be called upon when the item is clicked in the menu.

Scripte Windows Download Forms

Add a click event to the MenuItem that launches the desired script. Start-Process provides a clean way to do this within a try/catch block so that you can make sure any errors launching the script (such as PowerShell not being available or the script not existing at the provided path) fall to your catch block.

Sdd the remaining logic to provide an exit condition for the launcher followed by returning your newly created MenuItem back to be assigned to another variable at runtime.

You should now have the New-MenuItem function created! The final function should look like this:

Test the New-MenuItem function by copying and pasting the above code into your PowerShell console and running the function providing some fake parameter values. You’ll see that a .NET MenuItem object is returned.

Creating A Launcher Form

Want more tips like this? Check out my personal PowerShell blog at: https://nkasco.com/FriendsOfATA

Now that you can easily create new menu items, it’s time to create a system tray launcher which will display the menu.

Create a basic form object to add components to. This doesn’t need to be anything fancy as it will be hidden to the end user and will keep the console running in the background as well.

Next, create the icon that will show up in the system tray. Below I’ve chosen to use the PowerShell icon. At runtime, the below code creates an actual system tray icon. This icon can be customized to your liking by setting the SystrayIcon variable to your desired icon.

Check out the documentation for the System.Drawing.Icon class to see other methods in which you can load an icon into memory.

When the script is run, you should then see a PowerShell icon show up in your system tray as you can see below.

Now, create a container for your menu items with a new ContextMenu object and create all of your menu items. For this example, the menu will have two scripts to run and an exit option.

Next, add all of the menu items just created to the context menu. This will ensure each menu option shows up in the form context menu.

Show the Launcher Form

Scripte Windows Download Format

Now that the form is complete, the last thing to do is to show it while ensuring the PowerShell console window doesn’t come up. Do this by using your Start-HideConsole , displaying the launcher form and then showing the console again withStart-ShowConsole to prevent a hung powershell.exe process.

Want more tips like this? Check out my personal PowerShell blog at: https://nkasco.com/FriendsOfATA

The full code in its entirety can be found here: https://github.com/nkasco/PSSystrayLauncher

Your Takeaways

Congrats, you’ve finished this project! In this article you learned:

  1. How to expose components of the Windows API.
  2. How to work with context menus via WinForms and add subsequent menu items.
  3. How to create a system tray icon in PowerShell.

Scripte Windows Download Form Download

This Project should give you enough understanding and experience to create your own systray menu for your PowerShell scripts!

Related