Upload from CMSOURE
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
@@ -0,0 +1,57 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This script is a template that allows you to extend the toolkit with your own custom functions.
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
The script is automatically dot-sourced by the AppDeployToolkitMain.ps1 script.
|
||||||
|
.NOTES
|
||||||
|
Toolkit Exit Code Ranges:
|
||||||
|
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
|
||||||
|
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
|
||||||
|
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
)
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
# Variables: Script
|
||||||
|
[string]$appDeployToolkitExtName = 'PSAppDeployToolkitExt'
|
||||||
|
[string]$appDeployExtScriptFriendlyName = 'App Deploy Toolkit Extensions'
|
||||||
|
[version]$appDeployExtScriptVersion = [version]'1.5.0'
|
||||||
|
[string]$appDeployExtScriptDate = '02/12/2017'
|
||||||
|
[hashtable]$appDeployExtScriptParameters = $PSBoundParameters
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
# <Your custom functions go here>
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
If ($scriptParentPath) {
|
||||||
|
Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] dot-source invoked by [$(((Get-Variable -Name MyInvocation).Value).ScriptName)]" -Source $appDeployToolkitExtName
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] invoked directly" -Source $appDeployToolkitExtName
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Displays a graphical console to browse the help for the App Deployment Toolkit functions
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
Displays a graphical console to browse the help for the App Deployment Toolkit functions
|
||||||
|
.EXAMPLE
|
||||||
|
AppDeployToolkitHelp.ps1
|
||||||
|
.NOTES
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
## Variables: Script
|
||||||
|
[string]$appDeployToolkitHelpName = 'PSAppDeployToolkitHelp'
|
||||||
|
[string]$appDeployHelpScriptFriendlyName = 'App Deploy Toolkit Help'
|
||||||
|
[version]$appDeployHelpScriptVersion = [version]'3.6.5'
|
||||||
|
[string]$appDeployHelpScriptDate = '02/12/2017'
|
||||||
|
|
||||||
|
## Variables: Environment
|
||||||
|
[string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
# Dot source the App Deploy Toolkit Functions
|
||||||
|
. "$scriptDirectory\AppDeployToolkitMain.ps1" -DisableLogging
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
Function Show-HelpConsole {
|
||||||
|
## Import the Assemblies
|
||||||
|
Add-Type -AssemblyName 'System.Windows.Forms' -ErrorAction 'Stop'
|
||||||
|
Add-Type -AssemblyName System.Drawing -ErrorAction 'Stop'
|
||||||
|
|
||||||
|
## Form Objects
|
||||||
|
$HelpForm = New-Object -TypeName 'System.Windows.Forms.Form'
|
||||||
|
$HelpListBox = New-Object -TypeName 'System.Windows.Forms.ListBox'
|
||||||
|
$HelpTextBox = New-Object -TypeName 'System.Windows.Forms.RichTextBox'
|
||||||
|
$InitialFormWindowState = New-Object -TypeName 'System.Windows.Forms.FormWindowState'
|
||||||
|
|
||||||
|
## Form Code
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 665
|
||||||
|
$System_Drawing_Size.Width = 957
|
||||||
|
$HelpForm.ClientSize = $System_Drawing_Size
|
||||||
|
$HelpForm.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpForm.Name = 'HelpForm'
|
||||||
|
$HelpForm.Text = 'PowerShell App Deployment Toolkit Help Console'
|
||||||
|
$HelpForm.WindowState = 'Normal'
|
||||||
|
$HelpForm.ShowInTaskbar = $true
|
||||||
|
$HelpForm.FormBorderStyle = 'Fixed3D'
|
||||||
|
$HelpForm.MaximizeBox = $false
|
||||||
|
$HelpForm.Icon = New-Object -TypeName 'System.Drawing.Icon' -ArgumentList $AppDeployLogoIcon
|
||||||
|
$HelpListBox.Anchor = 7
|
||||||
|
$HelpListBox.BorderStyle = 1
|
||||||
|
$HelpListBox.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpListBox.Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList ('Microsoft Sans Serif', 9.75, 1, 3, 1)
|
||||||
|
$HelpListBox.FormattingEnabled = $true
|
||||||
|
$HelpListBox.ItemHeight = 16
|
||||||
|
$System_Drawing_Point = New-Object -TypeName 'System.Drawing.Point'
|
||||||
|
$System_Drawing_Point.X = 0
|
||||||
|
$System_Drawing_Point.Y = 0
|
||||||
|
$HelpListBox.Location = $System_Drawing_Point
|
||||||
|
$HelpListBox.Name = 'HelpListBox'
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 658
|
||||||
|
$System_Drawing_Size.Width = 271
|
||||||
|
$HelpListBox.Size = $System_Drawing_Size
|
||||||
|
$HelpListBox.Sorted = $true
|
||||||
|
$HelpListBox.TabIndex = 2
|
||||||
|
$HelpListBox.add_SelectedIndexChanged({ $HelpTextBox.Text = Get-Help -Name $HelpListBox.SelectedItem -Full | Out-String })
|
||||||
|
$helpFunctions = Get-Command -CommandType 'Function' | Where-Object { ($_.HelpUri -match 'psappdeploytoolkit') -and ($_.Definition -notmatch 'internal script function') } | Select-Object -ExpandProperty Name
|
||||||
|
ForEach ($helpFunction in $helpFunctions) {
|
||||||
|
$null = $HelpListBox.Items.Add($helpFunction)
|
||||||
|
}
|
||||||
|
$HelpForm.Controls.Add($HelpListBox)
|
||||||
|
$HelpTextBox.Anchor = 11
|
||||||
|
$HelpTextBox.BorderStyle = 1
|
||||||
|
$HelpTextBox.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpTextBox.Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList ('Microsoft Sans Serif', 8.5, 0, 3, 1)
|
||||||
|
$HelpTextBox.ForeColor = [System.Drawing.Color]::FromArgb(255, 0, 0, 0)
|
||||||
|
$System_Drawing_Point = New-Object -TypeName System.Drawing.Point
|
||||||
|
$System_Drawing_Point.X = 277
|
||||||
|
$System_Drawing_Point.Y = 0
|
||||||
|
$HelpTextBox.Location = $System_Drawing_Point
|
||||||
|
$HelpTextBox.Name = 'HelpTextBox'
|
||||||
|
$HelpTextBox.ReadOnly = $True
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 658
|
||||||
|
$System_Drawing_Size.Width = 680
|
||||||
|
$HelpTextBox.Size = $System_Drawing_Size
|
||||||
|
$HelpTextBox.TabIndex = 1
|
||||||
|
$HelpTextBox.Text = ''
|
||||||
|
$HelpForm.Controls.Add($HelpTextBox)
|
||||||
|
|
||||||
|
## Save the initial state of the form
|
||||||
|
$InitialFormWindowState = $HelpForm.WindowState
|
||||||
|
## Init the OnLoad event to correct the initial state of the form
|
||||||
|
$HelpForm.add_Load($OnLoadForm_StateCorrection)
|
||||||
|
## Show the Form
|
||||||
|
$null = $HelpForm.ShowDialog()
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
Write-Log -Message "Load [$appDeployHelpScriptFriendlyName] console..." -Source $appDeployToolkitHelpName
|
||||||
|
|
||||||
|
## Show the help console
|
||||||
|
Show-HelpConsole
|
||||||
|
|
||||||
|
Write-Log -Message "[$appDeployHelpScriptFriendlyName] console closed." -Source $appDeployToolkitHelpName
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 293 KiB |
@@ -0,0 +1,775 @@
|
|||||||
|
// Date Modified: 01-08-2016
|
||||||
|
// Version Number: 3.6.8
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.DirectoryServices;
|
||||||
|
using System.Security.Principal;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
|
||||||
|
|
||||||
|
namespace PSADT
|
||||||
|
{
|
||||||
|
public class Msi
|
||||||
|
{
|
||||||
|
enum LoadLibraryFlags : int
|
||||||
|
{
|
||||||
|
DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
|
||||||
|
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
|
||||||
|
LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
|
||||||
|
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
|
||||||
|
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
|
||||||
|
LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, LoadLibraryFlags dwFlags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern int LoadString(IntPtr hInstance, int uID, StringBuilder lpBuffer, int nBufferMax);
|
||||||
|
|
||||||
|
// Get MSI exit code message from msimsg.dll resource dll
|
||||||
|
public static string GetMessageFromMsiExitCode(int errCode)
|
||||||
|
{
|
||||||
|
IntPtr hModuleInstance = LoadLibraryEx("msimsg.dll", IntPtr.Zero, LoadLibraryFlags.LOAD_LIBRARY_AS_DATAFILE);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder(255);
|
||||||
|
LoadString(hModuleInstance, errCode, sb, sb.Capacity + 1);
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Explorer
|
||||||
|
{
|
||||||
|
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
|
||||||
|
private const int WM_SETTINGCHANGE = 0x1a;
|
||||||
|
private const int SMTO_ABORTIFHUNG = 0x0002;
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern bool SendNotifyMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
|
||||||
|
|
||||||
|
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
|
||||||
|
|
||||||
|
public static void RefreshDesktopAndEnvironmentVariables()
|
||||||
|
{
|
||||||
|
// Update desktop icons
|
||||||
|
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
|
||||||
|
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
|
||||||
|
// Update environment variables
|
||||||
|
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "Environment", SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class FileVerb
|
||||||
|
{
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int LoadString(IntPtr h, int id, StringBuilder sb, int maxBuffer);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr LoadLibrary(string s);
|
||||||
|
|
||||||
|
public static string GetPinVerb(int VerbId)
|
||||||
|
{
|
||||||
|
IntPtr hShell32 = LoadLibrary("shell32.dll");
|
||||||
|
const int nChars = 255;
|
||||||
|
StringBuilder Buff = new StringBuilder("", nChars);
|
||||||
|
|
||||||
|
LoadString(hShell32, VerbId, Buff, Buff.Capacity);
|
||||||
|
return Buff.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class IniFile
|
||||||
|
{
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, StringBuilder lpString, string lpFileName);
|
||||||
|
|
||||||
|
public static string GetIniValue(string section, string key, string filepath)
|
||||||
|
{
|
||||||
|
string sDefault = "";
|
||||||
|
const int nChars = 1024;
|
||||||
|
StringBuilder Buff = new StringBuilder(nChars);
|
||||||
|
|
||||||
|
GetPrivateProfileString(section, key, sDefault, Buff, Buff.Capacity, filepath);
|
||||||
|
return Buff.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetIniValue(string section, string key, StringBuilder value, string filepath)
|
||||||
|
{
|
||||||
|
WritePrivateProfileString(section, key, value, filepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UiAutomation
|
||||||
|
{
|
||||||
|
public enum GetWindow_Cmd : int
|
||||||
|
{
|
||||||
|
GW_HWNDFIRST = 0,
|
||||||
|
GW_HWNDLAST = 1,
|
||||||
|
GW_HWNDNEXT = 2,
|
||||||
|
GW_HWNDPREV = 3,
|
||||||
|
GW_OWNER = 4,
|
||||||
|
GW_CHILD = 5,
|
||||||
|
GW_ENABLEDPOPUP = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ShowWindowEnum
|
||||||
|
{
|
||||||
|
Hide = 0,
|
||||||
|
ShowNormal = 1,
|
||||||
|
ShowMinimized = 2,
|
||||||
|
ShowMaximized = 3,
|
||||||
|
Maximize = 3,
|
||||||
|
ShowNormalNoActivate = 4,
|
||||||
|
Show = 5,
|
||||||
|
Minimize = 6,
|
||||||
|
ShowMinNoActivate = 7,
|
||||||
|
ShowNoActivate = 8,
|
||||||
|
Restore = 9,
|
||||||
|
ShowDefault = 10,
|
||||||
|
ForceMinimized = 11
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UserNotificationState
|
||||||
|
{
|
||||||
|
// http://msdn.microsoft.com/en-us/library/bb762533(v=vs.85).aspx
|
||||||
|
ScreenSaverOrLockedOrFastUserSwitching =1, // A screen saver is displayed, the machine is locked, or a nonactive Fast User Switching session is in progress.
|
||||||
|
FullScreenOrPresentationModeOrLoginScreen =2, // A full-screen application is running or Presentation Settings are applied. Presentation Settings allow a user to put their machine into a state fit for an uninterrupted presentation, such as a set of PowerPoint slides, with a single click. Also returns this state if machine is at the login screen.
|
||||||
|
RunningDirect3DFullScreen =3, // A full-screen, exclusive mode, Direct3D application is running.
|
||||||
|
PresentationMode =4, // The user has activated Windows presentation settings to block notifications and pop-up messages.
|
||||||
|
AcceptsNotifications =5, // None of the other states are found, notifications can be freely sent.
|
||||||
|
QuietTime =6, // Introduced in Windows 7. The current user is in "quiet time", which is the first hour after a new user logs into his or her account for the first time.
|
||||||
|
WindowsStoreAppRunning =7 // Introduced in Windows 8. A Windows Store app is running.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only for Vista or above
|
||||||
|
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern int SHQueryUserNotificationState(out UserNotificationState pquns);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool EnumWindows(EnumWindowsProcD lpEnumFunc, ref IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowTextLength(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr GetDesktopWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr GetShellWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool IsWindowEnabled(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool IsWindowVisible(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool IsIconic(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool ShowWindow(IntPtr hWnd, ShowWindowEnum flags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr SetActiveWindow(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetForegroundWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr SetFocus(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool BringWindowToTop(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetCurrentThreadId();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool AttachThreadInput(int idAttach, int idAttachTo, bool fAttach);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
public delegate bool EnumWindowsProcD(IntPtr hWnd, ref IntPtr lItems);
|
||||||
|
|
||||||
|
public static bool EnumWindowsProc(IntPtr hWnd, ref IntPtr lItems)
|
||||||
|
{
|
||||||
|
if (hWnd != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
GCHandle hItems = GCHandle.FromIntPtr(lItems);
|
||||||
|
List<IntPtr> items = hItems.Target as List<IntPtr>;
|
||||||
|
items.Add(hWnd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<IntPtr> EnumWindows()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<IntPtr> items = new List<IntPtr>();
|
||||||
|
EnumWindowsProcD CallBackPtr = new EnumWindowsProcD(EnumWindowsProc);
|
||||||
|
GCHandle hItems = GCHandle.Alloc(items);
|
||||||
|
IntPtr lItems = GCHandle.ToIntPtr(hItems);
|
||||||
|
EnumWindows(CallBackPtr, ref lItems);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("An error occured during window enumeration: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetWindowText(IntPtr hWnd)
|
||||||
|
{
|
||||||
|
int iTextLength = GetWindowTextLength(hWnd);
|
||||||
|
if (iTextLength > 0)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(iTextLength);
|
||||||
|
GetWindowText(hWnd, sb, iTextLength + 1);
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool BringWindowToFront(IntPtr windowHandle)
|
||||||
|
{
|
||||||
|
bool breturn = false;
|
||||||
|
if (IsIconic(windowHandle))
|
||||||
|
{
|
||||||
|
// Show minimized window because SetForegroundWindow does not work for minimized windows
|
||||||
|
ShowWindow(windowHandle, ShowWindowEnum.ShowMaximized);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lpdwProcessId;
|
||||||
|
int windowThreadProcessId = GetWindowThreadProcessId(GetForegroundWindow(), out lpdwProcessId);
|
||||||
|
int currentThreadId = GetCurrentThreadId();
|
||||||
|
AttachThreadInput(windowThreadProcessId, currentThreadId, true);
|
||||||
|
|
||||||
|
BringWindowToTop(windowHandle);
|
||||||
|
breturn = SetForegroundWindow(windowHandle);
|
||||||
|
SetActiveWindow(windowHandle);
|
||||||
|
SetFocus(windowHandle);
|
||||||
|
|
||||||
|
AttachThreadInput(windowThreadProcessId, currentThreadId, false);
|
||||||
|
return breturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetWindowThreadProcessId(IntPtr windowHandle)
|
||||||
|
{
|
||||||
|
int processID = 0;
|
||||||
|
GetWindowThreadProcessId(windowHandle, out processID);
|
||||||
|
return processID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
|
||||||
|
{
|
||||||
|
if (IntPtr.Size == 4)
|
||||||
|
{
|
||||||
|
return GetWindowLong32(hWnd, nIndex);
|
||||||
|
}
|
||||||
|
return GetWindowLongPtr64(hWnd, nIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetUserNotificationState()
|
||||||
|
{
|
||||||
|
// Only works for Windows Vista or higher
|
||||||
|
UserNotificationState state;
|
||||||
|
int returnVal = SHQueryUserNotificationState(out state);
|
||||||
|
return state.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QueryUser
|
||||||
|
{
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr WTSOpenServer(string pServerName);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern void WTSCloseServer(IntPtr hServer);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Ansi, SetLastError = false)]
|
||||||
|
public static extern bool WTSQuerySessionInformation(IntPtr hServer, int sessionId, WTS_INFO_CLASS wtsInfoClass, out IntPtr pBuffer, out int pBytesReturned);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Ansi, SetLastError = false)]
|
||||||
|
public static extern int WTSEnumerateSessions(IntPtr hServer, int Reserved, int Version, out IntPtr pSessionInfo, out int pCount);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern void WTSFreeMemory(IntPtr pMemory);
|
||||||
|
|
||||||
|
[DllImport("winsta.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int WinStationQueryInformation(IntPtr hServer, int sessionId, int information, ref WINSTATIONINFORMATIONW pBuffer, int bufferLength, ref int returnedLength);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetCurrentProcessId();
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool ProcessIdToSessionId(int processId, ref int pSessionId);
|
||||||
|
|
||||||
|
public class TerminalSessionData
|
||||||
|
{
|
||||||
|
public int SessionId;
|
||||||
|
public string ConnectionState;
|
||||||
|
public string SessionName;
|
||||||
|
public bool IsUserSession;
|
||||||
|
public TerminalSessionData(int sessionId, string connState, string sessionName, bool isUserSession)
|
||||||
|
{
|
||||||
|
SessionId = sessionId;
|
||||||
|
ConnectionState = connState;
|
||||||
|
SessionName = sessionName;
|
||||||
|
IsUserSession = isUserSession;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TerminalSessionInfo
|
||||||
|
{
|
||||||
|
public string NTAccount;
|
||||||
|
public string SID;
|
||||||
|
public string UserName;
|
||||||
|
public string DomainName;
|
||||||
|
public int SessionId;
|
||||||
|
public string SessionName;
|
||||||
|
public string ConnectState;
|
||||||
|
public bool IsCurrentSession;
|
||||||
|
public bool IsConsoleSession;
|
||||||
|
public bool IsActiveUserSession;
|
||||||
|
public bool IsUserSession;
|
||||||
|
public bool IsRdpSession;
|
||||||
|
public bool IsLocalAdmin;
|
||||||
|
public DateTime? LogonTime;
|
||||||
|
public TimeSpan? IdleTime;
|
||||||
|
public DateTime? DisconnectTime;
|
||||||
|
public string ClientName;
|
||||||
|
public string ClientProtocolType;
|
||||||
|
public string ClientDirectory;
|
||||||
|
public int ClientBuildNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct WTS_SESSION_INFO
|
||||||
|
{
|
||||||
|
public Int32 SessionId;
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string SessionName;
|
||||||
|
public WTS_CONNECTSTATE_CLASS State;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct WINSTATIONINFORMATIONW
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 70)]
|
||||||
|
private byte[] Reserved1;
|
||||||
|
public int SessionId;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
|
private byte[] Reserved2;
|
||||||
|
public FILETIME ConnectTime;
|
||||||
|
public FILETIME DisconnectTime;
|
||||||
|
public FILETIME LastInputTime;
|
||||||
|
public FILETIME LoginTime;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1096)]
|
||||||
|
private byte[] Reserved3;
|
||||||
|
public FILETIME CurrentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WINSTATIONINFOCLASS
|
||||||
|
{
|
||||||
|
WinStationInformation = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WTS_CONNECTSTATE_CLASS
|
||||||
|
{
|
||||||
|
Active,
|
||||||
|
Connected,
|
||||||
|
ConnectQuery,
|
||||||
|
Shadow,
|
||||||
|
Disconnected,
|
||||||
|
Idle,
|
||||||
|
Listen,
|
||||||
|
Reset,
|
||||||
|
Down,
|
||||||
|
Init
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WTS_INFO_CLASS
|
||||||
|
{
|
||||||
|
SessionId=4,
|
||||||
|
UserName,
|
||||||
|
SessionName,
|
||||||
|
DomainName,
|
||||||
|
ConnectState,
|
||||||
|
ClientBuildNumber,
|
||||||
|
ClientName,
|
||||||
|
ClientDirectory,
|
||||||
|
ClientProtocolType=16
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IntPtr OpenServer(string Name)
|
||||||
|
{
|
||||||
|
IntPtr server = WTSOpenServer(Name);
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CloseServer(IntPtr ServerHandle)
|
||||||
|
{
|
||||||
|
WTSCloseServer(ServerHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IList<T> PtrToStructureList<T>(IntPtr ppList, int count) where T : struct
|
||||||
|
{
|
||||||
|
List<T> result = new List<T>();
|
||||||
|
long pointer = ppList.ToInt64();
|
||||||
|
int sizeOf = Marshal.SizeOf(typeof(T));
|
||||||
|
|
||||||
|
for (int index = 0; index < count; index++)
|
||||||
|
{
|
||||||
|
T item = (T) Marshal.PtrToStructure(new IntPtr(pointer), typeof(T));
|
||||||
|
result.Add(item);
|
||||||
|
pointer += sizeOf;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime? FileTimeToDateTime(FILETIME ft)
|
||||||
|
{
|
||||||
|
if (ft.dwHighDateTime == 0 && ft.dwLowDateTime == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
long hFT = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||||
|
return DateTime.FromFileTime(hFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WINSTATIONINFORMATIONW GetWinStationInformation(IntPtr server, int sessionId)
|
||||||
|
{
|
||||||
|
int retLen = 0;
|
||||||
|
WINSTATIONINFORMATIONW wsInfo = new WINSTATIONINFORMATIONW();
|
||||||
|
WinStationQueryInformation(server, sessionId, (int) WINSTATIONINFOCLASS.WinStationInformation, ref wsInfo, Marshal.SizeOf(typeof(WINSTATIONINFORMATIONW)), ref retLen);
|
||||||
|
return wsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionData[] ListSessions(string ServerName)
|
||||||
|
{
|
||||||
|
IntPtr server = IntPtr.Zero;
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TerminalSessionData> results = new List<TerminalSessionData>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
server = OpenServer(ServerName);
|
||||||
|
IntPtr ppSessionInfo = IntPtr.Zero;
|
||||||
|
int count;
|
||||||
|
bool _isUserSession = false;
|
||||||
|
IList<WTS_SESSION_INFO> sessionsInfo;
|
||||||
|
|
||||||
|
if (WTSEnumerateSessions(server, 0, 1, out ppSessionInfo, out count) == 0)
|
||||||
|
{
|
||||||
|
throw new Win32Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sessionsInfo = PtrToStructureList<WTS_SESSION_INFO>(ppSessionInfo, count);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
WTSFreeMemory(ppSessionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (WTS_SESSION_INFO sessionInfo in sessionsInfo)
|
||||||
|
{
|
||||||
|
if (sessionInfo.SessionName != "Services" && sessionInfo.SessionName != "RDP-Tcp")
|
||||||
|
{
|
||||||
|
_isUserSession = true;
|
||||||
|
}
|
||||||
|
results.Add(new TerminalSessionData(sessionInfo.SessionId, sessionInfo.State.ToString(), sessionInfo.SessionName, _isUserSession));
|
||||||
|
_isUserSession = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseServer(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalSessionData[] returnData = results.ToArray();
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionInfo GetSessionInfo(string ServerName, int SessionId)
|
||||||
|
{
|
||||||
|
IntPtr server = IntPtr.Zero;
|
||||||
|
IntPtr buffer = IntPtr.Zero;
|
||||||
|
int bytesReturned;
|
||||||
|
TerminalSessionInfo data = new TerminalSessionInfo();
|
||||||
|
bool _IsCurrentSessionId = false;
|
||||||
|
bool _IsConsoleSession = false;
|
||||||
|
bool _IsUserSession = false;
|
||||||
|
int currentSessionID = 0;
|
||||||
|
string _NTAccount = String.Empty;
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
if (ProcessIdToSessionId(GetCurrentProcessId(), ref currentSessionID) == false)
|
||||||
|
{
|
||||||
|
currentSessionID = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all members of the local administrators group
|
||||||
|
bool _IsLocalAdminCheckSuccess = false;
|
||||||
|
List<string> localAdminGroupSidsList = new List<string>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + ServerName + ",Computer");
|
||||||
|
string localAdminGroupName = new SecurityIdentifier("S-1-5-32-544").Translate(typeof(NTAccount)).Value.Split('\\')[1];
|
||||||
|
DirectoryEntry admGroup = localMachine.Children.Find(localAdminGroupName, "group");
|
||||||
|
object members = admGroup.Invoke("members", null);
|
||||||
|
foreach (object groupMember in (IEnumerable)members)
|
||||||
|
{
|
||||||
|
DirectoryEntry member = new DirectoryEntry(groupMember);
|
||||||
|
if (member.Name != String.Empty)
|
||||||
|
{
|
||||||
|
localAdminGroupSidsList.Add((new NTAccount(member.Name)).Translate(typeof(SecurityIdentifier)).Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_IsLocalAdminCheckSuccess = true;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
server = OpenServer(ServerName);
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientBuildNumber, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
int lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.ClientBuildNumber = lData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientDirectory, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
string strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.ClientDirectory = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.ClientName = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientProtocolType, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
Int16 intData = Marshal.ReadInt16(buffer);
|
||||||
|
if (intData == 2)
|
||||||
|
{
|
||||||
|
strData = "RDP";
|
||||||
|
data.IsRdpSession = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strData = "";
|
||||||
|
data.IsRdpSession = false;
|
||||||
|
}
|
||||||
|
data.ClientProtocolType = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ConnectState, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.ConnectState = ((WTS_CONNECTSTATE_CLASS) lData).ToString();
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.SessionId, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.SessionId = lData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.DomainName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer).ToUpper();
|
||||||
|
data.DomainName = strData;
|
||||||
|
if (strData != String.Empty)
|
||||||
|
{
|
||||||
|
_NTAccount = strData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.UserName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.UserName = strData;
|
||||||
|
if (strData != String.Empty)
|
||||||
|
{
|
||||||
|
data.NTAccount = _NTAccount + "\\" + strData;
|
||||||
|
string _Sid = (new NTAccount(_NTAccount + "\\" + strData)).Translate(typeof(SecurityIdentifier)).Value;
|
||||||
|
data.SID = _Sid;
|
||||||
|
if (_IsLocalAdminCheckSuccess == true)
|
||||||
|
{
|
||||||
|
foreach (string localAdminGroupSid in localAdminGroupSidsList)
|
||||||
|
{
|
||||||
|
if (localAdminGroupSid == _Sid)
|
||||||
|
{
|
||||||
|
data.IsLocalAdmin = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.IsLocalAdmin = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.SessionName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.SessionName = strData;
|
||||||
|
if (strData != "Services" && strData != "RDP-Tcp" && data.UserName != String.Empty)
|
||||||
|
{
|
||||||
|
_IsUserSession = true;
|
||||||
|
}
|
||||||
|
data.IsUserSession = _IsUserSession;
|
||||||
|
if (strData == "Console")
|
||||||
|
{
|
||||||
|
_IsConsoleSession = true;
|
||||||
|
}
|
||||||
|
data.IsConsoleSession = _IsConsoleSession;
|
||||||
|
|
||||||
|
WINSTATIONINFORMATIONW wsInfo = GetWinStationInformation(server, SessionId);
|
||||||
|
DateTime? _loginTime = FileTimeToDateTime(wsInfo.LoginTime);
|
||||||
|
DateTime? _lastInputTime = FileTimeToDateTime(wsInfo.LastInputTime);
|
||||||
|
DateTime? _disconnectTime = FileTimeToDateTime(wsInfo.DisconnectTime);
|
||||||
|
DateTime? _currentTime = FileTimeToDateTime(wsInfo.CurrentTime);
|
||||||
|
TimeSpan? _idleTime = (_currentTime != null && _lastInputTime != null) ? _currentTime.Value - _lastInputTime.Value : TimeSpan.Zero;
|
||||||
|
data.LogonTime = _loginTime;
|
||||||
|
data.IdleTime = _idleTime;
|
||||||
|
data.DisconnectTime = _disconnectTime;
|
||||||
|
|
||||||
|
if (currentSessionID == SessionId)
|
||||||
|
{
|
||||||
|
_IsCurrentSessionId = true;
|
||||||
|
}
|
||||||
|
data.IsCurrentSession = _IsCurrentSessionId;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
WTSFreeMemory(buffer);
|
||||||
|
buffer = IntPtr.Zero;
|
||||||
|
CloseServer(server);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionInfo[] GetUserSessionInfo(string ServerName)
|
||||||
|
{
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find and get detailed information for all user sessions
|
||||||
|
// Also determine the active user session. If a console user exists, then that will be the active user session.
|
||||||
|
// If no console user exists but users are logged in, such as on terminal servers, then select the first logged-in non-console user that is either 'Active' or 'Connected' as the active user.
|
||||||
|
TerminalSessionData[] sessions = ListSessions(ServerName);
|
||||||
|
TerminalSessionInfo sessionInfo = new TerminalSessionInfo();
|
||||||
|
List<TerminalSessionInfo> userSessionsInfo = new List<TerminalSessionInfo>();
|
||||||
|
string firstActiveUserNTAccount = String.Empty;
|
||||||
|
bool IsActiveUserSessionSet = false;
|
||||||
|
foreach (TerminalSessionData session in sessions)
|
||||||
|
{
|
||||||
|
if (session.IsUserSession == true)
|
||||||
|
{
|
||||||
|
sessionInfo = GetSessionInfo(ServerName, session.SessionId);
|
||||||
|
if (sessionInfo.IsUserSession == true)
|
||||||
|
{
|
||||||
|
if ((firstActiveUserNTAccount == String.Empty) && (sessionInfo.ConnectState == "Active" || sessionInfo.ConnectState == "Connected"))
|
||||||
|
{
|
||||||
|
firstActiveUserNTAccount = sessionInfo.NTAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sessionInfo.IsConsoleSession == true)
|
||||||
|
{
|
||||||
|
sessionInfo.IsActiveUserSession = true;
|
||||||
|
IsActiveUserSessionSet = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sessionInfo.IsActiveUserSession = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
userSessionsInfo.Add(sessionInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalSessionInfo[] userSessions = userSessionsInfo.ToArray();
|
||||||
|
if (IsActiveUserSessionSet == false)
|
||||||
|
{
|
||||||
|
foreach (TerminalSessionInfo userSession in userSessions)
|
||||||
|
{
|
||||||
|
if (userSession.NTAccount == firstActiveUserNTAccount)
|
||||||
|
{
|
||||||
|
userSession.IsActiveUserSession = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return userSessions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10830
CFX Maestro/1.1/PS_Deployment/AppDeployToolkit/AppDeployToolkitMain.ps1
Normal file
10830
CFX Maestro/1.1/PS_Deployment/AppDeployToolkit/AppDeployToolkitMain.ps1
Normal file
File diff suppressed because it is too large
Load Diff
BIN
CFX Maestro/1.1/PS_Deployment/AppDeployToolkit/Thumbs.db
Normal file
BIN
CFX Maestro/1.1/PS_Deployment/AppDeployToolkit/Thumbs.db
Normal file
Binary file not shown.
BIN
CFX Maestro/1.1/PS_Deployment/Deploy-Application.exe
Normal file
BIN
CFX Maestro/1.1/PS_Deployment/Deploy-Application.exe
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0"/>
|
||||||
|
<supportedRuntime version="v2.0.50727"/>
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
235
CFX Maestro/1.1/PS_Deployment/Deploy-Application.ps1
Normal file
235
CFX Maestro/1.1/PS_Deployment/Deploy-Application.ps1
Normal file
@@ -0,0 +1,235 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This script performs the installation or uninstallation of an application(s).
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
The script is provided as a template to perform an install or uninstall of an application(s).
|
||||||
|
The script either performs an "Install" deployment type or an "Uninstall" deployment type.
|
||||||
|
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
|
||||||
|
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
|
||||||
|
.PARAMETER DeploymentType
|
||||||
|
The type of deployment to perform. Default is: Install.
|
||||||
|
.PARAMETER DeployMode
|
||||||
|
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
|
||||||
|
.PARAMETER AllowRebootPassThru
|
||||||
|
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
|
||||||
|
.PARAMETER TerminalServerMode
|
||||||
|
Changes to "user install mode" and back to "user execute mode" for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
|
||||||
|
.PARAMETER DisableLogging
|
||||||
|
Disables logging to file for the script. Default is: $false.
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeployMode 'Silent'; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -AllowRebootPassThru; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeploymentType 'Uninstall'; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
Deploy-Application.exe -DeploymentType "Install" -DeployMode "Silent"
|
||||||
|
.NOTES
|
||||||
|
Toolkit Exit Code Ranges:
|
||||||
|
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
|
||||||
|
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
|
||||||
|
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[ValidateSet('Install','Uninstall')]
|
||||||
|
[string]$DeploymentType = 'Install',
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[ValidateSet('Interactive','Silent','NonInteractive')]
|
||||||
|
[string]$DeployMode = 'Interactive',
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$AllowRebootPassThru = $false,
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$TerminalServerMode = $false,
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$DisableLogging = $false
|
||||||
|
)
|
||||||
|
|
||||||
|
Try {
|
||||||
|
## Set the script execution policy for this process
|
||||||
|
Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
## Variables: Application
|
||||||
|
[string]$appVendor = 'Bio-Rad'
|
||||||
|
[string]$appName = 'CFX Maestro'
|
||||||
|
[string]$appVersion = '1.1'
|
||||||
|
[string]$appArch = 'x86'
|
||||||
|
[string]$appLang = 'EN'
|
||||||
|
[string]$appRevision = '01'
|
||||||
|
[string]$appScriptVersion = '1.0.0'
|
||||||
|
[string]$appScriptDate = '04/23/2018'
|
||||||
|
[string]$appScriptAuthor = 'John Palmer'
|
||||||
|
##*===============================================
|
||||||
|
## Variables: Install Titles (Only set here to override defaults set by the toolkit)
|
||||||
|
[string]$installName = ''
|
||||||
|
[string]$installTitle = ''
|
||||||
|
|
||||||
|
##* Do not modify section below
|
||||||
|
#region DoNotModify
|
||||||
|
|
||||||
|
## Variables: Exit Code
|
||||||
|
[int32]$mainExitCode = 0
|
||||||
|
|
||||||
|
## Variables: Script
|
||||||
|
[string]$deployAppScriptFriendlyName = 'Deploy Application'
|
||||||
|
[version]$deployAppScriptVersion = [version]'3.7.0'
|
||||||
|
[string]$deployAppScriptDate = '02/13/2018'
|
||||||
|
[hashtable]$deployAppScriptParameters = $psBoundParameters
|
||||||
|
|
||||||
|
## Variables: Environment
|
||||||
|
If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
|
||||||
|
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
## Dot source the required App Deploy Toolkit Functions
|
||||||
|
Try {
|
||||||
|
[string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
|
||||||
|
If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
|
||||||
|
If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
|
||||||
|
Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
|
||||||
|
## Exit the script, returning the exit code to SCCM
|
||||||
|
If (Test-Path -LiteralPath 'variable:HostInvocation') { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
##* Do not modify section above
|
||||||
|
##*===============================================
|
||||||
|
##* END VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
If ($deploymentType -ine 'Uninstall') {
|
||||||
|
##*===============================================
|
||||||
|
##* PRE-INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Pre-Installation'
|
||||||
|
|
||||||
|
## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
|
||||||
|
Show-InstallationWelcome -CloseApps 'BioRadC1000Server, BioRadCFXManager, BioRADMiniOpticonDiscovery' #-AllowDefer -DeferTimes 3 -CheckDiskSpace -PersistPrompt
|
||||||
|
|
||||||
|
## Show Progress Message (with the default message)
|
||||||
|
Show-InstallationProgress
|
||||||
|
|
||||||
|
## <Perform Pre-Installation tasks here>
|
||||||
|
|
||||||
|
## Import the Trusted Certs required for installation. ##
|
||||||
|
|
||||||
|
Copy-File -Path "$dirSupportFiles\*.cer" -Destination 'C:\TEMP\'
|
||||||
|
|
||||||
|
# The following only works on W10, so I left it for futue reference #
|
||||||
|
|
||||||
|
#Import-Certificate "C:\TEMP\BioRad.cer" -CertStoreLocation Cert:\LocalMachine\TrustedPublisher\
|
||||||
|
|
||||||
|
#Import-Certificate "C:\TEMP\Jungo.cer" -CertStoreLocation Cert:\LocalMachine\TrustedPublisher\
|
||||||
|
|
||||||
|
certutil -addstore "TrustedPublisher" C:\TEMP\BioRad.cer
|
||||||
|
|
||||||
|
certutil -addstore "TrustedPublisher" C:\TEMP\Jungo.cer
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Installation'
|
||||||
|
|
||||||
|
## Handle Zero-Config MSI Installations
|
||||||
|
If ($useDefaultMsi) {
|
||||||
|
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Install'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
|
||||||
|
Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ } }
|
||||||
|
}
|
||||||
|
|
||||||
|
## <Perform Installation tasks here>
|
||||||
|
|
||||||
|
## MSI Example with a Transform -> Execute-MSI -Action Install -Path 'Application.msi' -Transform 'TrasformFile.mst'
|
||||||
|
|
||||||
|
## .EXE Example -> Execute-Process -Path 'setup.exe' -Parameters '/S'
|
||||||
|
|
||||||
|
Execute-Process -Path "$dirFiles\CFX\CFXMaestroSetup1.1.exe" -Parameters '/S /v/qn'
|
||||||
|
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* POST-INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Post-Installation'
|
||||||
|
|
||||||
|
## <Perform Post-Installation tasks here>
|
||||||
|
|
||||||
|
## Remove the Certificates that were copied locally for import.
|
||||||
|
|
||||||
|
Remove-Item 'C:\TEMP' -Recurse
|
||||||
|
|
||||||
|
## Display a message at the end of the install
|
||||||
|
If (-not $useDefaultMsi) { Show-InstallationPrompt -Message 'You can customize text to appear at the end of an install or remove it completely for unattended installations.' -ButtonRightText 'OK' -Icon Information -NoWait }
|
||||||
|
}
|
||||||
|
ElseIf ($deploymentType -ieq 'Uninstall')
|
||||||
|
{
|
||||||
|
##*===============================================
|
||||||
|
##* PRE-UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Pre-Uninstallation'
|
||||||
|
|
||||||
|
## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
|
||||||
|
Show-InstallationWelcome -CloseApps 'BioRadC1000Server, BioRadCFXManager, BioRADMiniOpticonDiscovery' -CloseAppsCountdown 60
|
||||||
|
|
||||||
|
## Show Progress Message (with the default message)
|
||||||
|
Show-InstallationProgress
|
||||||
|
|
||||||
|
## <Perform Pre-Uninstallation tasks here>
|
||||||
|
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Uninstallation'
|
||||||
|
|
||||||
|
## Handle Zero-Config MSI Uninstallations
|
||||||
|
If ($useDefaultMsi) {
|
||||||
|
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Uninstall'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
|
||||||
|
Execute-MSI @ExecuteDefaultMSISplat
|
||||||
|
}
|
||||||
|
|
||||||
|
# <Perform Uninstallation tasks here>
|
||||||
|
|
||||||
|
#Uninstall MSI Example
|
||||||
|
#Execute-MSI -Action Uninstall -Path '{6E6D2BB7-B844-4842-B62D-0A7F0AA7884E}' -Parameters '/q /norestart'
|
||||||
|
|
||||||
|
Execute-MSI -Action Uninstall -Path '{AD42E531-6D66-4493-AEEB-E01AFC28B5A2}'
|
||||||
|
|
||||||
|
Remove-Item 'C:\TEMP' -Recurse
|
||||||
|
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* POST-UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Post-Uninstallation'
|
||||||
|
|
||||||
|
## <Perform Post-Uninstallation tasks here>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
## Call the Exit-Script function to perform final cleanup operations
|
||||||
|
Exit-Script -ExitCode $mainExitCode
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
[int32]$mainExitCode = 60001
|
||||||
|
[string]$mainErrorMessage = "$(Resolve-Error)"
|
||||||
|
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
|
||||||
|
Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
|
||||||
|
Exit-Script -ExitCode $mainExitCode
|
||||||
|
}
|
||||||
BIN
CFX Maestro/1.1/PS_Deployment/Install - CFX Maestro.lnk
Normal file
BIN
CFX Maestro/1.1/PS_Deployment/Install - CFX Maestro.lnk
Normal file
Binary file not shown.
1
CFX Maestro/1.1/PS_Deployment/Readme.txt
Normal file
1
CFX Maestro/1.1/PS_Deployment/Readme.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Instructions for using this script are included in the PSAppDeployToolkitAdminGuide document in the "Examples" section.
|
||||||
BIN
CFX Maestro/1.1/PS_Deployment/SupportFiles/BioRad.cer
Normal file
BIN
CFX Maestro/1.1/PS_Deployment/SupportFiles/BioRad.cer
Normal file
Binary file not shown.
BIN
CFX Maestro/1.1/PS_Deployment/SupportFiles/Jungo.cer
Normal file
BIN
CFX Maestro/1.1/PS_Deployment/SupportFiles/Jungo.cer
Normal file
Binary file not shown.
BIN
CFX Maestro/1.1/PS_Deployment/Uninstall - CFX Maestro.lnk
Normal file
BIN
CFX Maestro/1.1/PS_Deployment/Uninstall - CFX Maestro.lnk
Normal file
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
@@ -0,0 +1,57 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This script is a template that allows you to extend the toolkit with your own custom functions.
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
The script is automatically dot-sourced by the AppDeployToolkitMain.ps1 script.
|
||||||
|
.NOTES
|
||||||
|
Toolkit Exit Code Ranges:
|
||||||
|
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
|
||||||
|
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
|
||||||
|
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
)
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
# Variables: Script
|
||||||
|
[string]$appDeployToolkitExtName = 'PSAppDeployToolkitExt'
|
||||||
|
[string]$appDeployExtScriptFriendlyName = 'App Deploy Toolkit Extensions'
|
||||||
|
[version]$appDeployExtScriptVersion = [version]'1.5.0'
|
||||||
|
[string]$appDeployExtScriptDate = '02/12/2017'
|
||||||
|
[hashtable]$appDeployExtScriptParameters = $PSBoundParameters
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
# <Your custom functions go here>
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
If ($scriptParentPath) {
|
||||||
|
Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] dot-source invoked by [$(((Get-Variable -Name MyInvocation).Value).ScriptName)]" -Source $appDeployToolkitExtName
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] invoked directly" -Source $appDeployToolkitExtName
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Displays a graphical console to browse the help for the App Deployment Toolkit functions
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
Displays a graphical console to browse the help for the App Deployment Toolkit functions
|
||||||
|
.EXAMPLE
|
||||||
|
AppDeployToolkitHelp.ps1
|
||||||
|
.NOTES
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
## Variables: Script
|
||||||
|
[string]$appDeployToolkitHelpName = 'PSAppDeployToolkitHelp'
|
||||||
|
[string]$appDeployHelpScriptFriendlyName = 'App Deploy Toolkit Help'
|
||||||
|
[version]$appDeployHelpScriptVersion = [version]'3.6.5'
|
||||||
|
[string]$appDeployHelpScriptDate = '02/12/2017'
|
||||||
|
|
||||||
|
## Variables: Environment
|
||||||
|
[string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
# Dot source the App Deploy Toolkit Functions
|
||||||
|
. "$scriptDirectory\AppDeployToolkitMain.ps1" -DisableLogging
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
Function Show-HelpConsole {
|
||||||
|
## Import the Assemblies
|
||||||
|
Add-Type -AssemblyName 'System.Windows.Forms' -ErrorAction 'Stop'
|
||||||
|
Add-Type -AssemblyName System.Drawing -ErrorAction 'Stop'
|
||||||
|
|
||||||
|
## Form Objects
|
||||||
|
$HelpForm = New-Object -TypeName 'System.Windows.Forms.Form'
|
||||||
|
$HelpListBox = New-Object -TypeName 'System.Windows.Forms.ListBox'
|
||||||
|
$HelpTextBox = New-Object -TypeName 'System.Windows.Forms.RichTextBox'
|
||||||
|
$InitialFormWindowState = New-Object -TypeName 'System.Windows.Forms.FormWindowState'
|
||||||
|
|
||||||
|
## Form Code
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 665
|
||||||
|
$System_Drawing_Size.Width = 957
|
||||||
|
$HelpForm.ClientSize = $System_Drawing_Size
|
||||||
|
$HelpForm.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpForm.Name = 'HelpForm'
|
||||||
|
$HelpForm.Text = 'PowerShell App Deployment Toolkit Help Console'
|
||||||
|
$HelpForm.WindowState = 'Normal'
|
||||||
|
$HelpForm.ShowInTaskbar = $true
|
||||||
|
$HelpForm.FormBorderStyle = 'Fixed3D'
|
||||||
|
$HelpForm.MaximizeBox = $false
|
||||||
|
$HelpForm.Icon = New-Object -TypeName 'System.Drawing.Icon' -ArgumentList $AppDeployLogoIcon
|
||||||
|
$HelpListBox.Anchor = 7
|
||||||
|
$HelpListBox.BorderStyle = 1
|
||||||
|
$HelpListBox.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpListBox.Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList ('Microsoft Sans Serif', 9.75, 1, 3, 1)
|
||||||
|
$HelpListBox.FormattingEnabled = $true
|
||||||
|
$HelpListBox.ItemHeight = 16
|
||||||
|
$System_Drawing_Point = New-Object -TypeName 'System.Drawing.Point'
|
||||||
|
$System_Drawing_Point.X = 0
|
||||||
|
$System_Drawing_Point.Y = 0
|
||||||
|
$HelpListBox.Location = $System_Drawing_Point
|
||||||
|
$HelpListBox.Name = 'HelpListBox'
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 658
|
||||||
|
$System_Drawing_Size.Width = 271
|
||||||
|
$HelpListBox.Size = $System_Drawing_Size
|
||||||
|
$HelpListBox.Sorted = $true
|
||||||
|
$HelpListBox.TabIndex = 2
|
||||||
|
$HelpListBox.add_SelectedIndexChanged({ $HelpTextBox.Text = Get-Help -Name $HelpListBox.SelectedItem -Full | Out-String })
|
||||||
|
$helpFunctions = Get-Command -CommandType 'Function' | Where-Object { ($_.HelpUri -match 'psappdeploytoolkit') -and ($_.Definition -notmatch 'internal script function') } | Select-Object -ExpandProperty Name
|
||||||
|
ForEach ($helpFunction in $helpFunctions) {
|
||||||
|
$null = $HelpListBox.Items.Add($helpFunction)
|
||||||
|
}
|
||||||
|
$HelpForm.Controls.Add($HelpListBox)
|
||||||
|
$HelpTextBox.Anchor = 11
|
||||||
|
$HelpTextBox.BorderStyle = 1
|
||||||
|
$HelpTextBox.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpTextBox.Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList ('Microsoft Sans Serif', 8.5, 0, 3, 1)
|
||||||
|
$HelpTextBox.ForeColor = [System.Drawing.Color]::FromArgb(255, 0, 0, 0)
|
||||||
|
$System_Drawing_Point = New-Object -TypeName System.Drawing.Point
|
||||||
|
$System_Drawing_Point.X = 277
|
||||||
|
$System_Drawing_Point.Y = 0
|
||||||
|
$HelpTextBox.Location = $System_Drawing_Point
|
||||||
|
$HelpTextBox.Name = 'HelpTextBox'
|
||||||
|
$HelpTextBox.ReadOnly = $True
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 658
|
||||||
|
$System_Drawing_Size.Width = 680
|
||||||
|
$HelpTextBox.Size = $System_Drawing_Size
|
||||||
|
$HelpTextBox.TabIndex = 1
|
||||||
|
$HelpTextBox.Text = ''
|
||||||
|
$HelpForm.Controls.Add($HelpTextBox)
|
||||||
|
|
||||||
|
## Save the initial state of the form
|
||||||
|
$InitialFormWindowState = $HelpForm.WindowState
|
||||||
|
## Init the OnLoad event to correct the initial state of the form
|
||||||
|
$HelpForm.add_Load($OnLoadForm_StateCorrection)
|
||||||
|
## Show the Form
|
||||||
|
$null = $HelpForm.ShowDialog()
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
Write-Log -Message "Load [$appDeployHelpScriptFriendlyName] console..." -Source $appDeployToolkitHelpName
|
||||||
|
|
||||||
|
## Show the help console
|
||||||
|
Show-HelpConsole
|
||||||
|
|
||||||
|
Write-Log -Message "[$appDeployHelpScriptFriendlyName] console closed." -Source $appDeployToolkitHelpName
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 293 KiB |
@@ -0,0 +1,775 @@
|
|||||||
|
// Date Modified: 01-08-2016
|
||||||
|
// Version Number: 3.6.8
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.DirectoryServices;
|
||||||
|
using System.Security.Principal;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
|
||||||
|
|
||||||
|
namespace PSADT
|
||||||
|
{
|
||||||
|
public class Msi
|
||||||
|
{
|
||||||
|
enum LoadLibraryFlags : int
|
||||||
|
{
|
||||||
|
DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
|
||||||
|
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
|
||||||
|
LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
|
||||||
|
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
|
||||||
|
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
|
||||||
|
LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, LoadLibraryFlags dwFlags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern int LoadString(IntPtr hInstance, int uID, StringBuilder lpBuffer, int nBufferMax);
|
||||||
|
|
||||||
|
// Get MSI exit code message from msimsg.dll resource dll
|
||||||
|
public static string GetMessageFromMsiExitCode(int errCode)
|
||||||
|
{
|
||||||
|
IntPtr hModuleInstance = LoadLibraryEx("msimsg.dll", IntPtr.Zero, LoadLibraryFlags.LOAD_LIBRARY_AS_DATAFILE);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder(255);
|
||||||
|
LoadString(hModuleInstance, errCode, sb, sb.Capacity + 1);
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Explorer
|
||||||
|
{
|
||||||
|
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
|
||||||
|
private const int WM_SETTINGCHANGE = 0x1a;
|
||||||
|
private const int SMTO_ABORTIFHUNG = 0x0002;
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern bool SendNotifyMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
|
||||||
|
|
||||||
|
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
|
||||||
|
|
||||||
|
public static void RefreshDesktopAndEnvironmentVariables()
|
||||||
|
{
|
||||||
|
// Update desktop icons
|
||||||
|
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
|
||||||
|
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
|
||||||
|
// Update environment variables
|
||||||
|
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "Environment", SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class FileVerb
|
||||||
|
{
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int LoadString(IntPtr h, int id, StringBuilder sb, int maxBuffer);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr LoadLibrary(string s);
|
||||||
|
|
||||||
|
public static string GetPinVerb(int VerbId)
|
||||||
|
{
|
||||||
|
IntPtr hShell32 = LoadLibrary("shell32.dll");
|
||||||
|
const int nChars = 255;
|
||||||
|
StringBuilder Buff = new StringBuilder("", nChars);
|
||||||
|
|
||||||
|
LoadString(hShell32, VerbId, Buff, Buff.Capacity);
|
||||||
|
return Buff.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class IniFile
|
||||||
|
{
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, StringBuilder lpString, string lpFileName);
|
||||||
|
|
||||||
|
public static string GetIniValue(string section, string key, string filepath)
|
||||||
|
{
|
||||||
|
string sDefault = "";
|
||||||
|
const int nChars = 1024;
|
||||||
|
StringBuilder Buff = new StringBuilder(nChars);
|
||||||
|
|
||||||
|
GetPrivateProfileString(section, key, sDefault, Buff, Buff.Capacity, filepath);
|
||||||
|
return Buff.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetIniValue(string section, string key, StringBuilder value, string filepath)
|
||||||
|
{
|
||||||
|
WritePrivateProfileString(section, key, value, filepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UiAutomation
|
||||||
|
{
|
||||||
|
public enum GetWindow_Cmd : int
|
||||||
|
{
|
||||||
|
GW_HWNDFIRST = 0,
|
||||||
|
GW_HWNDLAST = 1,
|
||||||
|
GW_HWNDNEXT = 2,
|
||||||
|
GW_HWNDPREV = 3,
|
||||||
|
GW_OWNER = 4,
|
||||||
|
GW_CHILD = 5,
|
||||||
|
GW_ENABLEDPOPUP = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ShowWindowEnum
|
||||||
|
{
|
||||||
|
Hide = 0,
|
||||||
|
ShowNormal = 1,
|
||||||
|
ShowMinimized = 2,
|
||||||
|
ShowMaximized = 3,
|
||||||
|
Maximize = 3,
|
||||||
|
ShowNormalNoActivate = 4,
|
||||||
|
Show = 5,
|
||||||
|
Minimize = 6,
|
||||||
|
ShowMinNoActivate = 7,
|
||||||
|
ShowNoActivate = 8,
|
||||||
|
Restore = 9,
|
||||||
|
ShowDefault = 10,
|
||||||
|
ForceMinimized = 11
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UserNotificationState
|
||||||
|
{
|
||||||
|
// http://msdn.microsoft.com/en-us/library/bb762533(v=vs.85).aspx
|
||||||
|
ScreenSaverOrLockedOrFastUserSwitching =1, // A screen saver is displayed, the machine is locked, or a nonactive Fast User Switching session is in progress.
|
||||||
|
FullScreenOrPresentationModeOrLoginScreen =2, // A full-screen application is running or Presentation Settings are applied. Presentation Settings allow a user to put their machine into a state fit for an uninterrupted presentation, such as a set of PowerPoint slides, with a single click. Also returns this state if machine is at the login screen.
|
||||||
|
RunningDirect3DFullScreen =3, // A full-screen, exclusive mode, Direct3D application is running.
|
||||||
|
PresentationMode =4, // The user has activated Windows presentation settings to block notifications and pop-up messages.
|
||||||
|
AcceptsNotifications =5, // None of the other states are found, notifications can be freely sent.
|
||||||
|
QuietTime =6, // Introduced in Windows 7. The current user is in "quiet time", which is the first hour after a new user logs into his or her account for the first time.
|
||||||
|
WindowsStoreAppRunning =7 // Introduced in Windows 8. A Windows Store app is running.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only for Vista or above
|
||||||
|
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern int SHQueryUserNotificationState(out UserNotificationState pquns);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool EnumWindows(EnumWindowsProcD lpEnumFunc, ref IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowTextLength(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr GetDesktopWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr GetShellWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool IsWindowEnabled(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool IsWindowVisible(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool IsIconic(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool ShowWindow(IntPtr hWnd, ShowWindowEnum flags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr SetActiveWindow(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetForegroundWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr SetFocus(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool BringWindowToTop(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetCurrentThreadId();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool AttachThreadInput(int idAttach, int idAttachTo, bool fAttach);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
public delegate bool EnumWindowsProcD(IntPtr hWnd, ref IntPtr lItems);
|
||||||
|
|
||||||
|
public static bool EnumWindowsProc(IntPtr hWnd, ref IntPtr lItems)
|
||||||
|
{
|
||||||
|
if (hWnd != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
GCHandle hItems = GCHandle.FromIntPtr(lItems);
|
||||||
|
List<IntPtr> items = hItems.Target as List<IntPtr>;
|
||||||
|
items.Add(hWnd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<IntPtr> EnumWindows()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<IntPtr> items = new List<IntPtr>();
|
||||||
|
EnumWindowsProcD CallBackPtr = new EnumWindowsProcD(EnumWindowsProc);
|
||||||
|
GCHandle hItems = GCHandle.Alloc(items);
|
||||||
|
IntPtr lItems = GCHandle.ToIntPtr(hItems);
|
||||||
|
EnumWindows(CallBackPtr, ref lItems);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("An error occured during window enumeration: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetWindowText(IntPtr hWnd)
|
||||||
|
{
|
||||||
|
int iTextLength = GetWindowTextLength(hWnd);
|
||||||
|
if (iTextLength > 0)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(iTextLength);
|
||||||
|
GetWindowText(hWnd, sb, iTextLength + 1);
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool BringWindowToFront(IntPtr windowHandle)
|
||||||
|
{
|
||||||
|
bool breturn = false;
|
||||||
|
if (IsIconic(windowHandle))
|
||||||
|
{
|
||||||
|
// Show minimized window because SetForegroundWindow does not work for minimized windows
|
||||||
|
ShowWindow(windowHandle, ShowWindowEnum.ShowMaximized);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lpdwProcessId;
|
||||||
|
int windowThreadProcessId = GetWindowThreadProcessId(GetForegroundWindow(), out lpdwProcessId);
|
||||||
|
int currentThreadId = GetCurrentThreadId();
|
||||||
|
AttachThreadInput(windowThreadProcessId, currentThreadId, true);
|
||||||
|
|
||||||
|
BringWindowToTop(windowHandle);
|
||||||
|
breturn = SetForegroundWindow(windowHandle);
|
||||||
|
SetActiveWindow(windowHandle);
|
||||||
|
SetFocus(windowHandle);
|
||||||
|
|
||||||
|
AttachThreadInput(windowThreadProcessId, currentThreadId, false);
|
||||||
|
return breturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetWindowThreadProcessId(IntPtr windowHandle)
|
||||||
|
{
|
||||||
|
int processID = 0;
|
||||||
|
GetWindowThreadProcessId(windowHandle, out processID);
|
||||||
|
return processID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
|
||||||
|
{
|
||||||
|
if (IntPtr.Size == 4)
|
||||||
|
{
|
||||||
|
return GetWindowLong32(hWnd, nIndex);
|
||||||
|
}
|
||||||
|
return GetWindowLongPtr64(hWnd, nIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetUserNotificationState()
|
||||||
|
{
|
||||||
|
// Only works for Windows Vista or higher
|
||||||
|
UserNotificationState state;
|
||||||
|
int returnVal = SHQueryUserNotificationState(out state);
|
||||||
|
return state.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QueryUser
|
||||||
|
{
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr WTSOpenServer(string pServerName);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern void WTSCloseServer(IntPtr hServer);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Ansi, SetLastError = false)]
|
||||||
|
public static extern bool WTSQuerySessionInformation(IntPtr hServer, int sessionId, WTS_INFO_CLASS wtsInfoClass, out IntPtr pBuffer, out int pBytesReturned);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Ansi, SetLastError = false)]
|
||||||
|
public static extern int WTSEnumerateSessions(IntPtr hServer, int Reserved, int Version, out IntPtr pSessionInfo, out int pCount);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern void WTSFreeMemory(IntPtr pMemory);
|
||||||
|
|
||||||
|
[DllImport("winsta.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int WinStationQueryInformation(IntPtr hServer, int sessionId, int information, ref WINSTATIONINFORMATIONW pBuffer, int bufferLength, ref int returnedLength);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetCurrentProcessId();
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool ProcessIdToSessionId(int processId, ref int pSessionId);
|
||||||
|
|
||||||
|
public class TerminalSessionData
|
||||||
|
{
|
||||||
|
public int SessionId;
|
||||||
|
public string ConnectionState;
|
||||||
|
public string SessionName;
|
||||||
|
public bool IsUserSession;
|
||||||
|
public TerminalSessionData(int sessionId, string connState, string sessionName, bool isUserSession)
|
||||||
|
{
|
||||||
|
SessionId = sessionId;
|
||||||
|
ConnectionState = connState;
|
||||||
|
SessionName = sessionName;
|
||||||
|
IsUserSession = isUserSession;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TerminalSessionInfo
|
||||||
|
{
|
||||||
|
public string NTAccount;
|
||||||
|
public string SID;
|
||||||
|
public string UserName;
|
||||||
|
public string DomainName;
|
||||||
|
public int SessionId;
|
||||||
|
public string SessionName;
|
||||||
|
public string ConnectState;
|
||||||
|
public bool IsCurrentSession;
|
||||||
|
public bool IsConsoleSession;
|
||||||
|
public bool IsActiveUserSession;
|
||||||
|
public bool IsUserSession;
|
||||||
|
public bool IsRdpSession;
|
||||||
|
public bool IsLocalAdmin;
|
||||||
|
public DateTime? LogonTime;
|
||||||
|
public TimeSpan? IdleTime;
|
||||||
|
public DateTime? DisconnectTime;
|
||||||
|
public string ClientName;
|
||||||
|
public string ClientProtocolType;
|
||||||
|
public string ClientDirectory;
|
||||||
|
public int ClientBuildNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct WTS_SESSION_INFO
|
||||||
|
{
|
||||||
|
public Int32 SessionId;
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string SessionName;
|
||||||
|
public WTS_CONNECTSTATE_CLASS State;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct WINSTATIONINFORMATIONW
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 70)]
|
||||||
|
private byte[] Reserved1;
|
||||||
|
public int SessionId;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
|
private byte[] Reserved2;
|
||||||
|
public FILETIME ConnectTime;
|
||||||
|
public FILETIME DisconnectTime;
|
||||||
|
public FILETIME LastInputTime;
|
||||||
|
public FILETIME LoginTime;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1096)]
|
||||||
|
private byte[] Reserved3;
|
||||||
|
public FILETIME CurrentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WINSTATIONINFOCLASS
|
||||||
|
{
|
||||||
|
WinStationInformation = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WTS_CONNECTSTATE_CLASS
|
||||||
|
{
|
||||||
|
Active,
|
||||||
|
Connected,
|
||||||
|
ConnectQuery,
|
||||||
|
Shadow,
|
||||||
|
Disconnected,
|
||||||
|
Idle,
|
||||||
|
Listen,
|
||||||
|
Reset,
|
||||||
|
Down,
|
||||||
|
Init
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WTS_INFO_CLASS
|
||||||
|
{
|
||||||
|
SessionId=4,
|
||||||
|
UserName,
|
||||||
|
SessionName,
|
||||||
|
DomainName,
|
||||||
|
ConnectState,
|
||||||
|
ClientBuildNumber,
|
||||||
|
ClientName,
|
||||||
|
ClientDirectory,
|
||||||
|
ClientProtocolType=16
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IntPtr OpenServer(string Name)
|
||||||
|
{
|
||||||
|
IntPtr server = WTSOpenServer(Name);
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CloseServer(IntPtr ServerHandle)
|
||||||
|
{
|
||||||
|
WTSCloseServer(ServerHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IList<T> PtrToStructureList<T>(IntPtr ppList, int count) where T : struct
|
||||||
|
{
|
||||||
|
List<T> result = new List<T>();
|
||||||
|
long pointer = ppList.ToInt64();
|
||||||
|
int sizeOf = Marshal.SizeOf(typeof(T));
|
||||||
|
|
||||||
|
for (int index = 0; index < count; index++)
|
||||||
|
{
|
||||||
|
T item = (T) Marshal.PtrToStructure(new IntPtr(pointer), typeof(T));
|
||||||
|
result.Add(item);
|
||||||
|
pointer += sizeOf;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime? FileTimeToDateTime(FILETIME ft)
|
||||||
|
{
|
||||||
|
if (ft.dwHighDateTime == 0 && ft.dwLowDateTime == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
long hFT = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||||
|
return DateTime.FromFileTime(hFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WINSTATIONINFORMATIONW GetWinStationInformation(IntPtr server, int sessionId)
|
||||||
|
{
|
||||||
|
int retLen = 0;
|
||||||
|
WINSTATIONINFORMATIONW wsInfo = new WINSTATIONINFORMATIONW();
|
||||||
|
WinStationQueryInformation(server, sessionId, (int) WINSTATIONINFOCLASS.WinStationInformation, ref wsInfo, Marshal.SizeOf(typeof(WINSTATIONINFORMATIONW)), ref retLen);
|
||||||
|
return wsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionData[] ListSessions(string ServerName)
|
||||||
|
{
|
||||||
|
IntPtr server = IntPtr.Zero;
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TerminalSessionData> results = new List<TerminalSessionData>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
server = OpenServer(ServerName);
|
||||||
|
IntPtr ppSessionInfo = IntPtr.Zero;
|
||||||
|
int count;
|
||||||
|
bool _isUserSession = false;
|
||||||
|
IList<WTS_SESSION_INFO> sessionsInfo;
|
||||||
|
|
||||||
|
if (WTSEnumerateSessions(server, 0, 1, out ppSessionInfo, out count) == 0)
|
||||||
|
{
|
||||||
|
throw new Win32Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sessionsInfo = PtrToStructureList<WTS_SESSION_INFO>(ppSessionInfo, count);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
WTSFreeMemory(ppSessionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (WTS_SESSION_INFO sessionInfo in sessionsInfo)
|
||||||
|
{
|
||||||
|
if (sessionInfo.SessionName != "Services" && sessionInfo.SessionName != "RDP-Tcp")
|
||||||
|
{
|
||||||
|
_isUserSession = true;
|
||||||
|
}
|
||||||
|
results.Add(new TerminalSessionData(sessionInfo.SessionId, sessionInfo.State.ToString(), sessionInfo.SessionName, _isUserSession));
|
||||||
|
_isUserSession = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseServer(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalSessionData[] returnData = results.ToArray();
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionInfo GetSessionInfo(string ServerName, int SessionId)
|
||||||
|
{
|
||||||
|
IntPtr server = IntPtr.Zero;
|
||||||
|
IntPtr buffer = IntPtr.Zero;
|
||||||
|
int bytesReturned;
|
||||||
|
TerminalSessionInfo data = new TerminalSessionInfo();
|
||||||
|
bool _IsCurrentSessionId = false;
|
||||||
|
bool _IsConsoleSession = false;
|
||||||
|
bool _IsUserSession = false;
|
||||||
|
int currentSessionID = 0;
|
||||||
|
string _NTAccount = String.Empty;
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
if (ProcessIdToSessionId(GetCurrentProcessId(), ref currentSessionID) == false)
|
||||||
|
{
|
||||||
|
currentSessionID = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all members of the local administrators group
|
||||||
|
bool _IsLocalAdminCheckSuccess = false;
|
||||||
|
List<string> localAdminGroupSidsList = new List<string>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + ServerName + ",Computer");
|
||||||
|
string localAdminGroupName = new SecurityIdentifier("S-1-5-32-544").Translate(typeof(NTAccount)).Value.Split('\\')[1];
|
||||||
|
DirectoryEntry admGroup = localMachine.Children.Find(localAdminGroupName, "group");
|
||||||
|
object members = admGroup.Invoke("members", null);
|
||||||
|
foreach (object groupMember in (IEnumerable)members)
|
||||||
|
{
|
||||||
|
DirectoryEntry member = new DirectoryEntry(groupMember);
|
||||||
|
if (member.Name != String.Empty)
|
||||||
|
{
|
||||||
|
localAdminGroupSidsList.Add((new NTAccount(member.Name)).Translate(typeof(SecurityIdentifier)).Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_IsLocalAdminCheckSuccess = true;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
server = OpenServer(ServerName);
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientBuildNumber, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
int lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.ClientBuildNumber = lData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientDirectory, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
string strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.ClientDirectory = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.ClientName = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientProtocolType, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
Int16 intData = Marshal.ReadInt16(buffer);
|
||||||
|
if (intData == 2)
|
||||||
|
{
|
||||||
|
strData = "RDP";
|
||||||
|
data.IsRdpSession = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strData = "";
|
||||||
|
data.IsRdpSession = false;
|
||||||
|
}
|
||||||
|
data.ClientProtocolType = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ConnectState, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.ConnectState = ((WTS_CONNECTSTATE_CLASS) lData).ToString();
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.SessionId, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.SessionId = lData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.DomainName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer).ToUpper();
|
||||||
|
data.DomainName = strData;
|
||||||
|
if (strData != String.Empty)
|
||||||
|
{
|
||||||
|
_NTAccount = strData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.UserName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.UserName = strData;
|
||||||
|
if (strData != String.Empty)
|
||||||
|
{
|
||||||
|
data.NTAccount = _NTAccount + "\\" + strData;
|
||||||
|
string _Sid = (new NTAccount(_NTAccount + "\\" + strData)).Translate(typeof(SecurityIdentifier)).Value;
|
||||||
|
data.SID = _Sid;
|
||||||
|
if (_IsLocalAdminCheckSuccess == true)
|
||||||
|
{
|
||||||
|
foreach (string localAdminGroupSid in localAdminGroupSidsList)
|
||||||
|
{
|
||||||
|
if (localAdminGroupSid == _Sid)
|
||||||
|
{
|
||||||
|
data.IsLocalAdmin = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.IsLocalAdmin = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.SessionName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.SessionName = strData;
|
||||||
|
if (strData != "Services" && strData != "RDP-Tcp" && data.UserName != String.Empty)
|
||||||
|
{
|
||||||
|
_IsUserSession = true;
|
||||||
|
}
|
||||||
|
data.IsUserSession = _IsUserSession;
|
||||||
|
if (strData == "Console")
|
||||||
|
{
|
||||||
|
_IsConsoleSession = true;
|
||||||
|
}
|
||||||
|
data.IsConsoleSession = _IsConsoleSession;
|
||||||
|
|
||||||
|
WINSTATIONINFORMATIONW wsInfo = GetWinStationInformation(server, SessionId);
|
||||||
|
DateTime? _loginTime = FileTimeToDateTime(wsInfo.LoginTime);
|
||||||
|
DateTime? _lastInputTime = FileTimeToDateTime(wsInfo.LastInputTime);
|
||||||
|
DateTime? _disconnectTime = FileTimeToDateTime(wsInfo.DisconnectTime);
|
||||||
|
DateTime? _currentTime = FileTimeToDateTime(wsInfo.CurrentTime);
|
||||||
|
TimeSpan? _idleTime = (_currentTime != null && _lastInputTime != null) ? _currentTime.Value - _lastInputTime.Value : TimeSpan.Zero;
|
||||||
|
data.LogonTime = _loginTime;
|
||||||
|
data.IdleTime = _idleTime;
|
||||||
|
data.DisconnectTime = _disconnectTime;
|
||||||
|
|
||||||
|
if (currentSessionID == SessionId)
|
||||||
|
{
|
||||||
|
_IsCurrentSessionId = true;
|
||||||
|
}
|
||||||
|
data.IsCurrentSession = _IsCurrentSessionId;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
WTSFreeMemory(buffer);
|
||||||
|
buffer = IntPtr.Zero;
|
||||||
|
CloseServer(server);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionInfo[] GetUserSessionInfo(string ServerName)
|
||||||
|
{
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find and get detailed information for all user sessions
|
||||||
|
// Also determine the active user session. If a console user exists, then that will be the active user session.
|
||||||
|
// If no console user exists but users are logged in, such as on terminal servers, then select the first logged-in non-console user that is either 'Active' or 'Connected' as the active user.
|
||||||
|
TerminalSessionData[] sessions = ListSessions(ServerName);
|
||||||
|
TerminalSessionInfo sessionInfo = new TerminalSessionInfo();
|
||||||
|
List<TerminalSessionInfo> userSessionsInfo = new List<TerminalSessionInfo>();
|
||||||
|
string firstActiveUserNTAccount = String.Empty;
|
||||||
|
bool IsActiveUserSessionSet = false;
|
||||||
|
foreach (TerminalSessionData session in sessions)
|
||||||
|
{
|
||||||
|
if (session.IsUserSession == true)
|
||||||
|
{
|
||||||
|
sessionInfo = GetSessionInfo(ServerName, session.SessionId);
|
||||||
|
if (sessionInfo.IsUserSession == true)
|
||||||
|
{
|
||||||
|
if ((firstActiveUserNTAccount == String.Empty) && (sessionInfo.ConnectState == "Active" || sessionInfo.ConnectState == "Connected"))
|
||||||
|
{
|
||||||
|
firstActiveUserNTAccount = sessionInfo.NTAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sessionInfo.IsConsoleSession == true)
|
||||||
|
{
|
||||||
|
sessionInfo.IsActiveUserSession = true;
|
||||||
|
IsActiveUserSessionSet = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sessionInfo.IsActiveUserSession = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
userSessionsInfo.Add(sessionInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalSessionInfo[] userSessions = userSessionsInfo.ToArray();
|
||||||
|
if (IsActiveUserSessionSet == false)
|
||||||
|
{
|
||||||
|
foreach (TerminalSessionInfo userSession in userSessions)
|
||||||
|
{
|
||||||
|
if (userSession.NTAccount == firstActiveUserNTAccount)
|
||||||
|
{
|
||||||
|
userSession.IsActiveUserSession = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return userSessions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10830
CFX Maestro/2.2/PS_Deployment/AppDeployToolkit/AppDeployToolkitMain.ps1
Normal file
10830
CFX Maestro/2.2/PS_Deployment/AppDeployToolkit/AppDeployToolkitMain.ps1
Normal file
File diff suppressed because it is too large
Load Diff
BIN
CFX Maestro/2.2/PS_Deployment/AppDeployToolkit/Thumbs.db
Normal file
BIN
CFX Maestro/2.2/PS_Deployment/AppDeployToolkit/Thumbs.db
Normal file
Binary file not shown.
BIN
CFX Maestro/2.2/PS_Deployment/Deploy-Application.exe
Normal file
BIN
CFX Maestro/2.2/PS_Deployment/Deploy-Application.exe
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0"/>
|
||||||
|
<supportedRuntime version="v2.0.50727"/>
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
226
CFX Maestro/2.2/PS_Deployment/Deploy-Application.ps1
Normal file
226
CFX Maestro/2.2/PS_Deployment/Deploy-Application.ps1
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This script performs the installation or uninstallation of an application(s).
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
The script is provided as a template to perform an install or uninstall of an application(s).
|
||||||
|
The script either performs an "Install" deployment type or an "Uninstall" deployment type.
|
||||||
|
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
|
||||||
|
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
|
||||||
|
.PARAMETER DeploymentType
|
||||||
|
The type of deployment to perform. Default is: Install.
|
||||||
|
.PARAMETER DeployMode
|
||||||
|
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
|
||||||
|
.PARAMETER AllowRebootPassThru
|
||||||
|
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
|
||||||
|
.PARAMETER TerminalServerMode
|
||||||
|
Changes to "user install mode" and back to "user execute mode" for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
|
||||||
|
.PARAMETER DisableLogging
|
||||||
|
Disables logging to file for the script. Default is: $false.
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeployMode 'Silent'; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -AllowRebootPassThru; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeploymentType 'Uninstall'; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
Deploy-Application.exe -DeploymentType "Install" -DeployMode "Silent"
|
||||||
|
.NOTES
|
||||||
|
Toolkit Exit Code Ranges:
|
||||||
|
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
|
||||||
|
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
|
||||||
|
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[ValidateSet('Install','Uninstall')]
|
||||||
|
[string]$DeploymentType = 'Install',
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[ValidateSet('Interactive','Silent','NonInteractive')]
|
||||||
|
[string]$DeployMode = 'Interactive',
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$AllowRebootPassThru = $false,
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$TerminalServerMode = $false,
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$DisableLogging = $false
|
||||||
|
)
|
||||||
|
|
||||||
|
Try {
|
||||||
|
## Set the script execution policy for this process
|
||||||
|
Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
## Variables: Application
|
||||||
|
[string]$appVendor = 'Bio-Rad'
|
||||||
|
[string]$appName = 'CFX Maestro'
|
||||||
|
[string]$appVersion = '2.2'
|
||||||
|
[string]$appArch = 'x86_x64'
|
||||||
|
[string]$appLang = 'EN'
|
||||||
|
[string]$appRevision = '01'
|
||||||
|
[string]$appScriptVersion = '1.0.0'
|
||||||
|
[string]$appScriptDate = '10/06/2021'
|
||||||
|
[string]$appScriptAuthor = 'Shawn Curtis'
|
||||||
|
##*===============================================
|
||||||
|
## Variables: Install Titles (Only set here to override defaults set by the toolkit)
|
||||||
|
[string]$installName = ''
|
||||||
|
[string]$installTitle = ''
|
||||||
|
|
||||||
|
##* Do not modify section below
|
||||||
|
#region DoNotModify
|
||||||
|
|
||||||
|
## Variables: Exit Code
|
||||||
|
[int32]$mainExitCode = 0
|
||||||
|
|
||||||
|
## Variables: Script
|
||||||
|
[string]$deployAppScriptFriendlyName = 'Deploy Application'
|
||||||
|
[version]$deployAppScriptVersion = [version]'3.7.0'
|
||||||
|
[string]$deployAppScriptDate = '02/13/2018'
|
||||||
|
[hashtable]$deployAppScriptParameters = $psBoundParameters
|
||||||
|
|
||||||
|
## Variables: Environment
|
||||||
|
If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
|
||||||
|
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
## Dot source the required App Deploy Toolkit Functions
|
||||||
|
Try {
|
||||||
|
[string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
|
||||||
|
If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
|
||||||
|
If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
|
||||||
|
Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
|
||||||
|
## Exit the script, returning the exit code to SCCM
|
||||||
|
If (Test-Path -LiteralPath 'variable:HostInvocation') { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
##* Do not modify section above
|
||||||
|
##*===============================================
|
||||||
|
##* END VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
If ($deploymentType -ine 'Uninstall') {
|
||||||
|
##*===============================================
|
||||||
|
##* PRE-INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Pre-Installation'
|
||||||
|
|
||||||
|
Write-Log "Closing related processses"
|
||||||
|
Show-InstallationWelcome -CloseApps 'BioRadC1000Server, BioRadCFXManager, BioRADMiniOpticonDiscovery'
|
||||||
|
|
||||||
|
## Show Progress Message (with the default message)
|
||||||
|
Show-InstallationProgress
|
||||||
|
|
||||||
|
## <Perform Pre-Installation tasks here>
|
||||||
|
|
||||||
|
## Import the Trusted Certs required for installation. ##
|
||||||
|
|
||||||
|
Copy-File -Path "$dirSupportFiles\*.cer" -Destination 'C:\TEMP\'
|
||||||
|
|
||||||
|
# The following only works on W10, so I left it for futue reference #
|
||||||
|
|
||||||
|
#Import-Certificate "C:\TEMP\BioRad.cer" -CertStoreLocation Cert:\LocalMachine\TrustedPublisher\
|
||||||
|
|
||||||
|
#Import-Certificate "C:\TEMP\Jungo.cer" -CertStoreLocation Cert:\LocalMachine\TrustedPublisher\
|
||||||
|
|
||||||
|
certutil -addstore "TrustedPublisher" C:\TEMP\BioRad.cer
|
||||||
|
|
||||||
|
certutil -addstore "TrustedPublisher" C:\TEMP\Jungo.cer
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Installation'
|
||||||
|
|
||||||
|
## Handle Zero-Config MSI Installations
|
||||||
|
If ($useDefaultMsi) {
|
||||||
|
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Install'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
|
||||||
|
Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ } }
|
||||||
|
}
|
||||||
|
|
||||||
|
## <Perform Installation tasks here>
|
||||||
|
|
||||||
|
Write-Log "Installing Bio-Rad CFX Maestro 2.2"
|
||||||
|
Execute-Process -Path "$dirFiles\CFX\CFXMaestroSetup.exe" -Parameters '/S /v/qn'
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* POST-INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Post-Installation'
|
||||||
|
|
||||||
|
## <Perform Post-Installation tasks here>
|
||||||
|
|
||||||
|
## Remove the Certificates that were copied locally for import.
|
||||||
|
|
||||||
|
Remove-Item 'C:\TEMP' -Recurse
|
||||||
|
|
||||||
|
}
|
||||||
|
ElseIf ($deploymentType -ieq 'Uninstall')
|
||||||
|
{
|
||||||
|
##*===============================================
|
||||||
|
##* PRE-UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Pre-Uninstallation'
|
||||||
|
|
||||||
|
## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
|
||||||
|
Show-InstallationWelcome -CloseApps 'BioRadC1000Server, BioRadCFXManager, BioRADMiniOpticonDiscovery' -CloseAppsCountdown 60
|
||||||
|
|
||||||
|
## Show Progress Message (with the default message)
|
||||||
|
Show-InstallationProgress
|
||||||
|
|
||||||
|
## <Perform Pre-Uninstallation tasks here>
|
||||||
|
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Uninstallation'
|
||||||
|
|
||||||
|
## Handle Zero-Config MSI Uninstallations
|
||||||
|
If ($useDefaultMsi) {
|
||||||
|
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Uninstall'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
|
||||||
|
Execute-MSI @ExecuteDefaultMSISplat
|
||||||
|
}
|
||||||
|
|
||||||
|
# <Perform Uninstallation tasks here>
|
||||||
|
|
||||||
|
#Removing CFX Maestro
|
||||||
|
Write-Log "Removing CFX Maestro."
|
||||||
|
Remove-MSIApplications -Name 'Maestro' -FilterApplication (,('Publisher', 'Bio-Rad Laboratories, Inc.', 'Exact'))
|
||||||
|
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* POST-UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Post-Uninstallation'
|
||||||
|
|
||||||
|
## <Perform Post-Uninstallation tasks here>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
## Call the Exit-Script function to perform final cleanup operations
|
||||||
|
Exit-Script -ExitCode $mainExitCode
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
[int32]$mainExitCode = 60001
|
||||||
|
[string]$mainErrorMessage = "$(Resolve-Error)"
|
||||||
|
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
|
||||||
|
Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
|
||||||
|
Exit-Script -ExitCode $mainExitCode
|
||||||
|
}
|
||||||
BIN
CFX Maestro/2.2/PS_Deployment/SupportFiles/BioRad.cer
Normal file
BIN
CFX Maestro/2.2/PS_Deployment/SupportFiles/BioRad.cer
Normal file
Binary file not shown.
BIN
CFX Maestro/2.2/PS_Deployment/SupportFiles/Jungo.cer
Normal file
BIN
CFX Maestro/2.2/PS_Deployment/SupportFiles/Jungo.cer
Normal file
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
@@ -0,0 +1,57 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This script is a template that allows you to extend the toolkit with your own custom functions.
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
The script is automatically dot-sourced by the AppDeployToolkitMain.ps1 script.
|
||||||
|
.NOTES
|
||||||
|
Toolkit Exit Code Ranges:
|
||||||
|
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
|
||||||
|
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
|
||||||
|
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
)
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
# Variables: Script
|
||||||
|
[string]$appDeployToolkitExtName = 'PSAppDeployToolkitExt'
|
||||||
|
[string]$appDeployExtScriptFriendlyName = 'App Deploy Toolkit Extensions'
|
||||||
|
[version]$appDeployExtScriptVersion = [version]'1.5.0'
|
||||||
|
[string]$appDeployExtScriptDate = '02/12/2017'
|
||||||
|
[hashtable]$appDeployExtScriptParameters = $PSBoundParameters
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
# <Your custom functions go here>
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
If ($scriptParentPath) {
|
||||||
|
Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] dot-source invoked by [$(((Get-Variable -Name MyInvocation).Value).ScriptName)]" -Source $appDeployToolkitExtName
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Log -Message "Script [$($MyInvocation.MyCommand.Definition)] invoked directly" -Source $appDeployToolkitExtName
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Displays a graphical console to browse the help for the App Deployment Toolkit functions
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
Displays a graphical console to browse the help for the App Deployment Toolkit functions
|
||||||
|
.EXAMPLE
|
||||||
|
AppDeployToolkitHelp.ps1
|
||||||
|
.NOTES
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
## Variables: Script
|
||||||
|
[string]$appDeployToolkitHelpName = 'PSAppDeployToolkitHelp'
|
||||||
|
[string]$appDeployHelpScriptFriendlyName = 'App Deploy Toolkit Help'
|
||||||
|
[version]$appDeployHelpScriptVersion = [version]'3.6.5'
|
||||||
|
[string]$appDeployHelpScriptDate = '02/12/2017'
|
||||||
|
|
||||||
|
## Variables: Environment
|
||||||
|
[string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
|
||||||
|
# Dot source the App Deploy Toolkit Functions
|
||||||
|
. "$scriptDirectory\AppDeployToolkitMain.ps1" -DisableLogging
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
Function Show-HelpConsole {
|
||||||
|
## Import the Assemblies
|
||||||
|
Add-Type -AssemblyName 'System.Windows.Forms' -ErrorAction 'Stop'
|
||||||
|
Add-Type -AssemblyName System.Drawing -ErrorAction 'Stop'
|
||||||
|
|
||||||
|
## Form Objects
|
||||||
|
$HelpForm = New-Object -TypeName 'System.Windows.Forms.Form'
|
||||||
|
$HelpListBox = New-Object -TypeName 'System.Windows.Forms.ListBox'
|
||||||
|
$HelpTextBox = New-Object -TypeName 'System.Windows.Forms.RichTextBox'
|
||||||
|
$InitialFormWindowState = New-Object -TypeName 'System.Windows.Forms.FormWindowState'
|
||||||
|
|
||||||
|
## Form Code
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 665
|
||||||
|
$System_Drawing_Size.Width = 957
|
||||||
|
$HelpForm.ClientSize = $System_Drawing_Size
|
||||||
|
$HelpForm.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpForm.Name = 'HelpForm'
|
||||||
|
$HelpForm.Text = 'PowerShell App Deployment Toolkit Help Console'
|
||||||
|
$HelpForm.WindowState = 'Normal'
|
||||||
|
$HelpForm.ShowInTaskbar = $true
|
||||||
|
$HelpForm.FormBorderStyle = 'Fixed3D'
|
||||||
|
$HelpForm.MaximizeBox = $false
|
||||||
|
$HelpForm.Icon = New-Object -TypeName 'System.Drawing.Icon' -ArgumentList $AppDeployLogoIcon
|
||||||
|
$HelpListBox.Anchor = 7
|
||||||
|
$HelpListBox.BorderStyle = 1
|
||||||
|
$HelpListBox.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpListBox.Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList ('Microsoft Sans Serif', 9.75, 1, 3, 1)
|
||||||
|
$HelpListBox.FormattingEnabled = $true
|
||||||
|
$HelpListBox.ItemHeight = 16
|
||||||
|
$System_Drawing_Point = New-Object -TypeName 'System.Drawing.Point'
|
||||||
|
$System_Drawing_Point.X = 0
|
||||||
|
$System_Drawing_Point.Y = 0
|
||||||
|
$HelpListBox.Location = $System_Drawing_Point
|
||||||
|
$HelpListBox.Name = 'HelpListBox'
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 658
|
||||||
|
$System_Drawing_Size.Width = 271
|
||||||
|
$HelpListBox.Size = $System_Drawing_Size
|
||||||
|
$HelpListBox.Sorted = $true
|
||||||
|
$HelpListBox.TabIndex = 2
|
||||||
|
$HelpListBox.add_SelectedIndexChanged({ $HelpTextBox.Text = Get-Help -Name $HelpListBox.SelectedItem -Full | Out-String })
|
||||||
|
$helpFunctions = Get-Command -CommandType 'Function' | Where-Object { ($_.HelpUri -match 'psappdeploytoolkit') -and ($_.Definition -notmatch 'internal script function') } | Select-Object -ExpandProperty Name
|
||||||
|
ForEach ($helpFunction in $helpFunctions) {
|
||||||
|
$null = $HelpListBox.Items.Add($helpFunction)
|
||||||
|
}
|
||||||
|
$HelpForm.Controls.Add($HelpListBox)
|
||||||
|
$HelpTextBox.Anchor = 11
|
||||||
|
$HelpTextBox.BorderStyle = 1
|
||||||
|
$HelpTextBox.DataBindings.DefaultDataSourceUpdateMode = 0
|
||||||
|
$HelpTextBox.Font = New-Object -TypeName 'System.Drawing.Font' -ArgumentList ('Microsoft Sans Serif', 8.5, 0, 3, 1)
|
||||||
|
$HelpTextBox.ForeColor = [System.Drawing.Color]::FromArgb(255, 0, 0, 0)
|
||||||
|
$System_Drawing_Point = New-Object -TypeName System.Drawing.Point
|
||||||
|
$System_Drawing_Point.X = 277
|
||||||
|
$System_Drawing_Point.Y = 0
|
||||||
|
$HelpTextBox.Location = $System_Drawing_Point
|
||||||
|
$HelpTextBox.Name = 'HelpTextBox'
|
||||||
|
$HelpTextBox.ReadOnly = $True
|
||||||
|
$System_Drawing_Size = New-Object -TypeName 'System.Drawing.Size'
|
||||||
|
$System_Drawing_Size.Height = 658
|
||||||
|
$System_Drawing_Size.Width = 680
|
||||||
|
$HelpTextBox.Size = $System_Drawing_Size
|
||||||
|
$HelpTextBox.TabIndex = 1
|
||||||
|
$HelpTextBox.Text = ''
|
||||||
|
$HelpForm.Controls.Add($HelpTextBox)
|
||||||
|
|
||||||
|
## Save the initial state of the form
|
||||||
|
$InitialFormWindowState = $HelpForm.WindowState
|
||||||
|
## Init the OnLoad event to correct the initial state of the form
|
||||||
|
$HelpForm.add_Load($OnLoadForm_StateCorrection)
|
||||||
|
## Show the Form
|
||||||
|
$null = $HelpForm.ShowDialog()
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END FUNCTION LISTINGS
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
Write-Log -Message "Load [$appDeployHelpScriptFriendlyName] console..." -Source $appDeployToolkitHelpName
|
||||||
|
|
||||||
|
## Show the help console
|
||||||
|
Show-HelpConsole
|
||||||
|
|
||||||
|
Write-Log -Message "[$appDeployHelpScriptFriendlyName] console closed." -Source $appDeployToolkitHelpName
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 293 KiB |
@@ -0,0 +1,775 @@
|
|||||||
|
// Date Modified: 01-08-2016
|
||||||
|
// Version Number: 3.6.8
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.DirectoryServices;
|
||||||
|
using System.Security.Principal;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
|
||||||
|
|
||||||
|
namespace PSADT
|
||||||
|
{
|
||||||
|
public class Msi
|
||||||
|
{
|
||||||
|
enum LoadLibraryFlags : int
|
||||||
|
{
|
||||||
|
DONT_RESOLVE_DLL_REFERENCES = 0x00000001,
|
||||||
|
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,
|
||||||
|
LOAD_LIBRARY_AS_DATAFILE = 0x00000002,
|
||||||
|
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,
|
||||||
|
LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,
|
||||||
|
LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, LoadLibraryFlags dwFlags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern int LoadString(IntPtr hInstance, int uID, StringBuilder lpBuffer, int nBufferMax);
|
||||||
|
|
||||||
|
// Get MSI exit code message from msimsg.dll resource dll
|
||||||
|
public static string GetMessageFromMsiExitCode(int errCode)
|
||||||
|
{
|
||||||
|
IntPtr hModuleInstance = LoadLibraryEx("msimsg.dll", IntPtr.Zero, LoadLibraryFlags.LOAD_LIBRARY_AS_DATAFILE);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder(255);
|
||||||
|
LoadString(hModuleInstance, errCode, sb, sb.Capacity + 1);
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Explorer
|
||||||
|
{
|
||||||
|
private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
|
||||||
|
private const int WM_SETTINGCHANGE = 0x1a;
|
||||||
|
private const int SMTO_ABORTIFHUNG = 0x0002;
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern bool SendNotifyMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, int fuFlags, int uTimeout, IntPtr lpdwResult);
|
||||||
|
|
||||||
|
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
|
||||||
|
|
||||||
|
public static void RefreshDesktopAndEnvironmentVariables()
|
||||||
|
{
|
||||||
|
// Update desktop icons
|
||||||
|
SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
|
||||||
|
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
|
||||||
|
// Update environment variables
|
||||||
|
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, "Environment", SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class FileVerb
|
||||||
|
{
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int LoadString(IntPtr h, int id, StringBuilder sb, int maxBuffer);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr LoadLibrary(string s);
|
||||||
|
|
||||||
|
public static string GetPinVerb(int VerbId)
|
||||||
|
{
|
||||||
|
IntPtr hShell32 = LoadLibrary("shell32.dll");
|
||||||
|
const int nChars = 255;
|
||||||
|
StringBuilder Buff = new StringBuilder("", nChars);
|
||||||
|
|
||||||
|
LoadString(hShell32, VerbId, Buff, Buff.Capacity);
|
||||||
|
return Buff.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class IniFile
|
||||||
|
{
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, StringBuilder lpString, string lpFileName);
|
||||||
|
|
||||||
|
public static string GetIniValue(string section, string key, string filepath)
|
||||||
|
{
|
||||||
|
string sDefault = "";
|
||||||
|
const int nChars = 1024;
|
||||||
|
StringBuilder Buff = new StringBuilder(nChars);
|
||||||
|
|
||||||
|
GetPrivateProfileString(section, key, sDefault, Buff, Buff.Capacity, filepath);
|
||||||
|
return Buff.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetIniValue(string section, string key, StringBuilder value, string filepath)
|
||||||
|
{
|
||||||
|
WritePrivateProfileString(section, key, value, filepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UiAutomation
|
||||||
|
{
|
||||||
|
public enum GetWindow_Cmd : int
|
||||||
|
{
|
||||||
|
GW_HWNDFIRST = 0,
|
||||||
|
GW_HWNDLAST = 1,
|
||||||
|
GW_HWNDNEXT = 2,
|
||||||
|
GW_HWNDPREV = 3,
|
||||||
|
GW_OWNER = 4,
|
||||||
|
GW_CHILD = 5,
|
||||||
|
GW_ENABLEDPOPUP = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ShowWindowEnum
|
||||||
|
{
|
||||||
|
Hide = 0,
|
||||||
|
ShowNormal = 1,
|
||||||
|
ShowMinimized = 2,
|
||||||
|
ShowMaximized = 3,
|
||||||
|
Maximize = 3,
|
||||||
|
ShowNormalNoActivate = 4,
|
||||||
|
Show = 5,
|
||||||
|
Minimize = 6,
|
||||||
|
ShowMinNoActivate = 7,
|
||||||
|
ShowNoActivate = 8,
|
||||||
|
Restore = 9,
|
||||||
|
ShowDefault = 10,
|
||||||
|
ForceMinimized = 11
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum UserNotificationState
|
||||||
|
{
|
||||||
|
// http://msdn.microsoft.com/en-us/library/bb762533(v=vs.85).aspx
|
||||||
|
ScreenSaverOrLockedOrFastUserSwitching =1, // A screen saver is displayed, the machine is locked, or a nonactive Fast User Switching session is in progress.
|
||||||
|
FullScreenOrPresentationModeOrLoginScreen =2, // A full-screen application is running or Presentation Settings are applied. Presentation Settings allow a user to put their machine into a state fit for an uninterrupted presentation, such as a set of PowerPoint slides, with a single click. Also returns this state if machine is at the login screen.
|
||||||
|
RunningDirect3DFullScreen =3, // A full-screen, exclusive mode, Direct3D application is running.
|
||||||
|
PresentationMode =4, // The user has activated Windows presentation settings to block notifications and pop-up messages.
|
||||||
|
AcceptsNotifications =5, // None of the other states are found, notifications can be freely sent.
|
||||||
|
QuietTime =6, // Introduced in Windows 7. The current user is in "quiet time", which is the first hour after a new user logs into his or her account for the first time.
|
||||||
|
WindowsStoreAppRunning =7 // Introduced in Windows 8. A Windows Store app is running.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only for Vista or above
|
||||||
|
[DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
static extern int SHQueryUserNotificationState(out UserNotificationState pquns);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool EnumWindows(EnumWindowsProcD lpEnumFunc, ref IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowTextLength(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr GetDesktopWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
private static extern IntPtr GetShellWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool IsWindowEnabled(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool IsWindowVisible(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool IsIconic(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool ShowWindow(IntPtr hWnd, ShowWindowEnum flags);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr SetActiveWindow(IntPtr hwnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetForegroundWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr SetFocus(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool BringWindowToTop(IntPtr hWnd);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetCurrentThreadId();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool AttachThreadInput(int idAttach, int idAttachTo, bool fAttach);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
public delegate bool EnumWindowsProcD(IntPtr hWnd, ref IntPtr lItems);
|
||||||
|
|
||||||
|
public static bool EnumWindowsProc(IntPtr hWnd, ref IntPtr lItems)
|
||||||
|
{
|
||||||
|
if (hWnd != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
GCHandle hItems = GCHandle.FromIntPtr(lItems);
|
||||||
|
List<IntPtr> items = hItems.Target as List<IntPtr>;
|
||||||
|
items.Add(hWnd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<IntPtr> EnumWindows()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<IntPtr> items = new List<IntPtr>();
|
||||||
|
EnumWindowsProcD CallBackPtr = new EnumWindowsProcD(EnumWindowsProc);
|
||||||
|
GCHandle hItems = GCHandle.Alloc(items);
|
||||||
|
IntPtr lItems = GCHandle.ToIntPtr(hItems);
|
||||||
|
EnumWindows(CallBackPtr, ref lItems);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw new Exception("An error occured during window enumeration: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetWindowText(IntPtr hWnd)
|
||||||
|
{
|
||||||
|
int iTextLength = GetWindowTextLength(hWnd);
|
||||||
|
if (iTextLength > 0)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder(iTextLength);
|
||||||
|
GetWindowText(hWnd, sb, iTextLength + 1);
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return String.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool BringWindowToFront(IntPtr windowHandle)
|
||||||
|
{
|
||||||
|
bool breturn = false;
|
||||||
|
if (IsIconic(windowHandle))
|
||||||
|
{
|
||||||
|
// Show minimized window because SetForegroundWindow does not work for minimized windows
|
||||||
|
ShowWindow(windowHandle, ShowWindowEnum.ShowMaximized);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lpdwProcessId;
|
||||||
|
int windowThreadProcessId = GetWindowThreadProcessId(GetForegroundWindow(), out lpdwProcessId);
|
||||||
|
int currentThreadId = GetCurrentThreadId();
|
||||||
|
AttachThreadInput(windowThreadProcessId, currentThreadId, true);
|
||||||
|
|
||||||
|
BringWindowToTop(windowHandle);
|
||||||
|
breturn = SetForegroundWindow(windowHandle);
|
||||||
|
SetActiveWindow(windowHandle);
|
||||||
|
SetFocus(windowHandle);
|
||||||
|
|
||||||
|
AttachThreadInput(windowThreadProcessId, currentThreadId, false);
|
||||||
|
return breturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetWindowThreadProcessId(IntPtr windowHandle)
|
||||||
|
{
|
||||||
|
int processID = 0;
|
||||||
|
GetWindowThreadProcessId(windowHandle, out processID);
|
||||||
|
return processID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
|
||||||
|
{
|
||||||
|
if (IntPtr.Size == 4)
|
||||||
|
{
|
||||||
|
return GetWindowLong32(hWnd, nIndex);
|
||||||
|
}
|
||||||
|
return GetWindowLongPtr64(hWnd, nIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetUserNotificationState()
|
||||||
|
{
|
||||||
|
// Only works for Windows Vista or higher
|
||||||
|
UserNotificationState state;
|
||||||
|
int returnVal = SHQueryUserNotificationState(out state);
|
||||||
|
return state.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class QueryUser
|
||||||
|
{
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern IntPtr WTSOpenServer(string pServerName);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern void WTSCloseServer(IntPtr hServer);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Ansi, SetLastError = false)]
|
||||||
|
public static extern bool WTSQuerySessionInformation(IntPtr hServer, int sessionId, WTS_INFO_CLASS wtsInfoClass, out IntPtr pBuffer, out int pBytesReturned);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Ansi, SetLastError = false)]
|
||||||
|
public static extern int WTSEnumerateSessions(IntPtr hServer, int Reserved, int Version, out IntPtr pSessionInfo, out int pCount);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern void WTSFreeMemory(IntPtr pMemory);
|
||||||
|
|
||||||
|
[DllImport("winsta.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int WinStationQueryInformation(IntPtr hServer, int sessionId, int information, ref WINSTATIONINFORMATIONW pBuffer, int bufferLength, ref int returnedLength);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern int GetCurrentProcessId();
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = false)]
|
||||||
|
public static extern bool ProcessIdToSessionId(int processId, ref int pSessionId);
|
||||||
|
|
||||||
|
public class TerminalSessionData
|
||||||
|
{
|
||||||
|
public int SessionId;
|
||||||
|
public string ConnectionState;
|
||||||
|
public string SessionName;
|
||||||
|
public bool IsUserSession;
|
||||||
|
public TerminalSessionData(int sessionId, string connState, string sessionName, bool isUserSession)
|
||||||
|
{
|
||||||
|
SessionId = sessionId;
|
||||||
|
ConnectionState = connState;
|
||||||
|
SessionName = sessionName;
|
||||||
|
IsUserSession = isUserSession;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TerminalSessionInfo
|
||||||
|
{
|
||||||
|
public string NTAccount;
|
||||||
|
public string SID;
|
||||||
|
public string UserName;
|
||||||
|
public string DomainName;
|
||||||
|
public int SessionId;
|
||||||
|
public string SessionName;
|
||||||
|
public string ConnectState;
|
||||||
|
public bool IsCurrentSession;
|
||||||
|
public bool IsConsoleSession;
|
||||||
|
public bool IsActiveUserSession;
|
||||||
|
public bool IsUserSession;
|
||||||
|
public bool IsRdpSession;
|
||||||
|
public bool IsLocalAdmin;
|
||||||
|
public DateTime? LogonTime;
|
||||||
|
public TimeSpan? IdleTime;
|
||||||
|
public DateTime? DisconnectTime;
|
||||||
|
public string ClientName;
|
||||||
|
public string ClientProtocolType;
|
||||||
|
public string ClientDirectory;
|
||||||
|
public int ClientBuildNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct WTS_SESSION_INFO
|
||||||
|
{
|
||||||
|
public Int32 SessionId;
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public string SessionName;
|
||||||
|
public WTS_CONNECTSTATE_CLASS State;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct WINSTATIONINFORMATIONW
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 70)]
|
||||||
|
private byte[] Reserved1;
|
||||||
|
public int SessionId;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||||
|
private byte[] Reserved2;
|
||||||
|
public FILETIME ConnectTime;
|
||||||
|
public FILETIME DisconnectTime;
|
||||||
|
public FILETIME LastInputTime;
|
||||||
|
public FILETIME LoginTime;
|
||||||
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1096)]
|
||||||
|
private byte[] Reserved3;
|
||||||
|
public FILETIME CurrentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WINSTATIONINFOCLASS
|
||||||
|
{
|
||||||
|
WinStationInformation = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WTS_CONNECTSTATE_CLASS
|
||||||
|
{
|
||||||
|
Active,
|
||||||
|
Connected,
|
||||||
|
ConnectQuery,
|
||||||
|
Shadow,
|
||||||
|
Disconnected,
|
||||||
|
Idle,
|
||||||
|
Listen,
|
||||||
|
Reset,
|
||||||
|
Down,
|
||||||
|
Init
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WTS_INFO_CLASS
|
||||||
|
{
|
||||||
|
SessionId=4,
|
||||||
|
UserName,
|
||||||
|
SessionName,
|
||||||
|
DomainName,
|
||||||
|
ConnectState,
|
||||||
|
ClientBuildNumber,
|
||||||
|
ClientName,
|
||||||
|
ClientDirectory,
|
||||||
|
ClientProtocolType=16
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IntPtr OpenServer(string Name)
|
||||||
|
{
|
||||||
|
IntPtr server = WTSOpenServer(Name);
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CloseServer(IntPtr ServerHandle)
|
||||||
|
{
|
||||||
|
WTSCloseServer(ServerHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IList<T> PtrToStructureList<T>(IntPtr ppList, int count) where T : struct
|
||||||
|
{
|
||||||
|
List<T> result = new List<T>();
|
||||||
|
long pointer = ppList.ToInt64();
|
||||||
|
int sizeOf = Marshal.SizeOf(typeof(T));
|
||||||
|
|
||||||
|
for (int index = 0; index < count; index++)
|
||||||
|
{
|
||||||
|
T item = (T) Marshal.PtrToStructure(new IntPtr(pointer), typeof(T));
|
||||||
|
result.Add(item);
|
||||||
|
pointer += sizeOf;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime? FileTimeToDateTime(FILETIME ft)
|
||||||
|
{
|
||||||
|
if (ft.dwHighDateTime == 0 && ft.dwLowDateTime == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
long hFT = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
|
||||||
|
return DateTime.FromFileTime(hFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WINSTATIONINFORMATIONW GetWinStationInformation(IntPtr server, int sessionId)
|
||||||
|
{
|
||||||
|
int retLen = 0;
|
||||||
|
WINSTATIONINFORMATIONW wsInfo = new WINSTATIONINFORMATIONW();
|
||||||
|
WinStationQueryInformation(server, sessionId, (int) WINSTATIONINFOCLASS.WinStationInformation, ref wsInfo, Marshal.SizeOf(typeof(WINSTATIONINFORMATIONW)), ref retLen);
|
||||||
|
return wsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionData[] ListSessions(string ServerName)
|
||||||
|
{
|
||||||
|
IntPtr server = IntPtr.Zero;
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TerminalSessionData> results = new List<TerminalSessionData>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
server = OpenServer(ServerName);
|
||||||
|
IntPtr ppSessionInfo = IntPtr.Zero;
|
||||||
|
int count;
|
||||||
|
bool _isUserSession = false;
|
||||||
|
IList<WTS_SESSION_INFO> sessionsInfo;
|
||||||
|
|
||||||
|
if (WTSEnumerateSessions(server, 0, 1, out ppSessionInfo, out count) == 0)
|
||||||
|
{
|
||||||
|
throw new Win32Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sessionsInfo = PtrToStructureList<WTS_SESSION_INFO>(ppSessionInfo, count);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
WTSFreeMemory(ppSessionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (WTS_SESSION_INFO sessionInfo in sessionsInfo)
|
||||||
|
{
|
||||||
|
if (sessionInfo.SessionName != "Services" && sessionInfo.SessionName != "RDP-Tcp")
|
||||||
|
{
|
||||||
|
_isUserSession = true;
|
||||||
|
}
|
||||||
|
results.Add(new TerminalSessionData(sessionInfo.SessionId, sessionInfo.State.ToString(), sessionInfo.SessionName, _isUserSession));
|
||||||
|
_isUserSession = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseServer(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalSessionData[] returnData = results.ToArray();
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionInfo GetSessionInfo(string ServerName, int SessionId)
|
||||||
|
{
|
||||||
|
IntPtr server = IntPtr.Zero;
|
||||||
|
IntPtr buffer = IntPtr.Zero;
|
||||||
|
int bytesReturned;
|
||||||
|
TerminalSessionInfo data = new TerminalSessionInfo();
|
||||||
|
bool _IsCurrentSessionId = false;
|
||||||
|
bool _IsConsoleSession = false;
|
||||||
|
bool _IsUserSession = false;
|
||||||
|
int currentSessionID = 0;
|
||||||
|
string _NTAccount = String.Empty;
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
if (ProcessIdToSessionId(GetCurrentProcessId(), ref currentSessionID) == false)
|
||||||
|
{
|
||||||
|
currentSessionID = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all members of the local administrators group
|
||||||
|
bool _IsLocalAdminCheckSuccess = false;
|
||||||
|
List<string> localAdminGroupSidsList = new List<string>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + ServerName + ",Computer");
|
||||||
|
string localAdminGroupName = new SecurityIdentifier("S-1-5-32-544").Translate(typeof(NTAccount)).Value.Split('\\')[1];
|
||||||
|
DirectoryEntry admGroup = localMachine.Children.Find(localAdminGroupName, "group");
|
||||||
|
object members = admGroup.Invoke("members", null);
|
||||||
|
foreach (object groupMember in (IEnumerable)members)
|
||||||
|
{
|
||||||
|
DirectoryEntry member = new DirectoryEntry(groupMember);
|
||||||
|
if (member.Name != String.Empty)
|
||||||
|
{
|
||||||
|
localAdminGroupSidsList.Add((new NTAccount(member.Name)).Translate(typeof(SecurityIdentifier)).Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_IsLocalAdminCheckSuccess = true;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
server = OpenServer(ServerName);
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientBuildNumber, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
int lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.ClientBuildNumber = lData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientDirectory, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
string strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.ClientDirectory = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.ClientName = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ClientProtocolType, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
Int16 intData = Marshal.ReadInt16(buffer);
|
||||||
|
if (intData == 2)
|
||||||
|
{
|
||||||
|
strData = "RDP";
|
||||||
|
data.IsRdpSession = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strData = "";
|
||||||
|
data.IsRdpSession = false;
|
||||||
|
}
|
||||||
|
data.ClientProtocolType = strData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.ConnectState, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.ConnectState = ((WTS_CONNECTSTATE_CLASS) lData).ToString();
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.SessionId, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
lData = Marshal.ReadInt32(buffer);
|
||||||
|
data.SessionId = lData;
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.DomainName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer).ToUpper();
|
||||||
|
data.DomainName = strData;
|
||||||
|
if (strData != String.Empty)
|
||||||
|
{
|
||||||
|
_NTAccount = strData;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.UserName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.UserName = strData;
|
||||||
|
if (strData != String.Empty)
|
||||||
|
{
|
||||||
|
data.NTAccount = _NTAccount + "\\" + strData;
|
||||||
|
string _Sid = (new NTAccount(_NTAccount + "\\" + strData)).Translate(typeof(SecurityIdentifier)).Value;
|
||||||
|
data.SID = _Sid;
|
||||||
|
if (_IsLocalAdminCheckSuccess == true)
|
||||||
|
{
|
||||||
|
foreach (string localAdminGroupSid in localAdminGroupSidsList)
|
||||||
|
{
|
||||||
|
if (localAdminGroupSid == _Sid)
|
||||||
|
{
|
||||||
|
data.IsLocalAdmin = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.IsLocalAdmin = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WTSQuerySessionInformation(server, SessionId, WTS_INFO_CLASS.SessionName, out buffer, out bytesReturned) == false)
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
strData = Marshal.PtrToStringAnsi(buffer);
|
||||||
|
data.SessionName = strData;
|
||||||
|
if (strData != "Services" && strData != "RDP-Tcp" && data.UserName != String.Empty)
|
||||||
|
{
|
||||||
|
_IsUserSession = true;
|
||||||
|
}
|
||||||
|
data.IsUserSession = _IsUserSession;
|
||||||
|
if (strData == "Console")
|
||||||
|
{
|
||||||
|
_IsConsoleSession = true;
|
||||||
|
}
|
||||||
|
data.IsConsoleSession = _IsConsoleSession;
|
||||||
|
|
||||||
|
WINSTATIONINFORMATIONW wsInfo = GetWinStationInformation(server, SessionId);
|
||||||
|
DateTime? _loginTime = FileTimeToDateTime(wsInfo.LoginTime);
|
||||||
|
DateTime? _lastInputTime = FileTimeToDateTime(wsInfo.LastInputTime);
|
||||||
|
DateTime? _disconnectTime = FileTimeToDateTime(wsInfo.DisconnectTime);
|
||||||
|
DateTime? _currentTime = FileTimeToDateTime(wsInfo.CurrentTime);
|
||||||
|
TimeSpan? _idleTime = (_currentTime != null && _lastInputTime != null) ? _currentTime.Value - _lastInputTime.Value : TimeSpan.Zero;
|
||||||
|
data.LogonTime = _loginTime;
|
||||||
|
data.IdleTime = _idleTime;
|
||||||
|
data.DisconnectTime = _disconnectTime;
|
||||||
|
|
||||||
|
if (currentSessionID == SessionId)
|
||||||
|
{
|
||||||
|
_IsCurrentSessionId = true;
|
||||||
|
}
|
||||||
|
data.IsCurrentSession = _IsCurrentSessionId;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
WTSFreeMemory(buffer);
|
||||||
|
buffer = IntPtr.Zero;
|
||||||
|
CloseServer(server);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerminalSessionInfo[] GetUserSessionInfo(string ServerName)
|
||||||
|
{
|
||||||
|
if (ServerName == "localhost" || ServerName == String.Empty)
|
||||||
|
{
|
||||||
|
ServerName = Environment.MachineName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find and get detailed information for all user sessions
|
||||||
|
// Also determine the active user session. If a console user exists, then that will be the active user session.
|
||||||
|
// If no console user exists but users are logged in, such as on terminal servers, then select the first logged-in non-console user that is either 'Active' or 'Connected' as the active user.
|
||||||
|
TerminalSessionData[] sessions = ListSessions(ServerName);
|
||||||
|
TerminalSessionInfo sessionInfo = new TerminalSessionInfo();
|
||||||
|
List<TerminalSessionInfo> userSessionsInfo = new List<TerminalSessionInfo>();
|
||||||
|
string firstActiveUserNTAccount = String.Empty;
|
||||||
|
bool IsActiveUserSessionSet = false;
|
||||||
|
foreach (TerminalSessionData session in sessions)
|
||||||
|
{
|
||||||
|
if (session.IsUserSession == true)
|
||||||
|
{
|
||||||
|
sessionInfo = GetSessionInfo(ServerName, session.SessionId);
|
||||||
|
if (sessionInfo.IsUserSession == true)
|
||||||
|
{
|
||||||
|
if ((firstActiveUserNTAccount == String.Empty) && (sessionInfo.ConnectState == "Active" || sessionInfo.ConnectState == "Connected"))
|
||||||
|
{
|
||||||
|
firstActiveUserNTAccount = sessionInfo.NTAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sessionInfo.IsConsoleSession == true)
|
||||||
|
{
|
||||||
|
sessionInfo.IsActiveUserSession = true;
|
||||||
|
IsActiveUserSessionSet = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sessionInfo.IsActiveUserSession = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
userSessionsInfo.Add(sessionInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TerminalSessionInfo[] userSessions = userSessionsInfo.ToArray();
|
||||||
|
if (IsActiveUserSessionSet == false)
|
||||||
|
{
|
||||||
|
foreach (TerminalSessionInfo userSession in userSessions)
|
||||||
|
{
|
||||||
|
if (userSession.NTAccount == firstActiveUserNTAccount)
|
||||||
|
{
|
||||||
|
userSession.IsActiveUserSession = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return userSessions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
BIN
CFX Maestro/2.3/PS_Deployment.old/AppDeployToolkit/Thumbs.db
Normal file
BIN
CFX Maestro/2.3/PS_Deployment.old/AppDeployToolkit/Thumbs.db
Normal file
Binary file not shown.
1300
CFX Maestro/2.3/PS_Deployment.old/AppDeployToolkitConfig.xml
Normal file
1300
CFX Maestro/2.3/PS_Deployment.old/AppDeployToolkitConfig.xml
Normal file
File diff suppressed because it is too large
Load Diff
BIN
CFX Maestro/2.3/PS_Deployment.old/Deploy-Application.exe
Normal file
BIN
CFX Maestro/2.3/PS_Deployment.old/Deploy-Application.exe
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0"/>
|
||||||
|
<supportedRuntime version="v2.0.50727"/>
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
226
CFX Maestro/2.3/PS_Deployment.old/Deploy-Application.ps1
Normal file
226
CFX Maestro/2.3/PS_Deployment.old/Deploy-Application.ps1
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
This script performs the installation or uninstallation of an application(s).
|
||||||
|
# LICENSE #
|
||||||
|
PowerShell App Deployment Toolkit - Provides a set of functions to perform common application deployment tasks on Windows.
|
||||||
|
Copyright (C) 2017 - Sean Lillis, Dan Cunningham, Muhammad Mashwani, Aman Motazedian.
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
.DESCRIPTION
|
||||||
|
The script is provided as a template to perform an install or uninstall of an application(s).
|
||||||
|
The script either performs an "Install" deployment type or an "Uninstall" deployment type.
|
||||||
|
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
|
||||||
|
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
|
||||||
|
.PARAMETER DeploymentType
|
||||||
|
The type of deployment to perform. Default is: Install.
|
||||||
|
.PARAMETER DeployMode
|
||||||
|
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
|
||||||
|
.PARAMETER AllowRebootPassThru
|
||||||
|
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
|
||||||
|
.PARAMETER TerminalServerMode
|
||||||
|
Changes to "user install mode" and back to "user execute mode" for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
|
||||||
|
.PARAMETER DisableLogging
|
||||||
|
Disables logging to file for the script. Default is: $false.
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeployMode 'Silent'; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -AllowRebootPassThru; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeploymentType 'Uninstall'; Exit $LastExitCode }"
|
||||||
|
.EXAMPLE
|
||||||
|
Deploy-Application.exe -DeploymentType "Install" -DeployMode "Silent"
|
||||||
|
.NOTES
|
||||||
|
Toolkit Exit Code Ranges:
|
||||||
|
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
|
||||||
|
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
|
||||||
|
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
|
||||||
|
.LINK
|
||||||
|
http://psappdeploytoolkit.com
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[ValidateSet('Install','Uninstall')]
|
||||||
|
[string]$DeploymentType = 'Install',
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[ValidateSet('Interactive','Silent','NonInteractive')]
|
||||||
|
[string]$DeployMode = 'Interactive',
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$AllowRebootPassThru = $false,
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$TerminalServerMode = $false,
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$DisableLogging = $false
|
||||||
|
)
|
||||||
|
|
||||||
|
Try {
|
||||||
|
## Set the script execution policy for this process
|
||||||
|
Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
## Variables: Application
|
||||||
|
[string]$appVendor = 'Bio-Rad'
|
||||||
|
[string]$appName = 'CFX Maestro'
|
||||||
|
[string]$appVersion = '2.3'
|
||||||
|
[string]$appArch = 'x86_x64'
|
||||||
|
[string]$appLang = 'EN'
|
||||||
|
[string]$appRevision = '01'
|
||||||
|
[string]$appScriptVersion = '1.0.0'
|
||||||
|
[string]$appScriptDate = '11/21/2023'
|
||||||
|
[string]$appScriptAuthor = 'John Palmer'
|
||||||
|
##*===============================================
|
||||||
|
## Variables: Install Titles (Only set here to override defaults set by the toolkit)
|
||||||
|
[string]$installName = ''
|
||||||
|
[string]$installTitle = ''
|
||||||
|
|
||||||
|
##* Do not modify section below
|
||||||
|
#region DoNotModify
|
||||||
|
|
||||||
|
## Variables: Exit Code
|
||||||
|
[int32]$mainExitCode = 0
|
||||||
|
|
||||||
|
## Variables: Script
|
||||||
|
[string]$deployAppScriptFriendlyName = 'Deploy Application'
|
||||||
|
[version]$deployAppScriptVersion = [version]'3.7.0'
|
||||||
|
[string]$deployAppScriptDate = '02/13/2018'
|
||||||
|
[hashtable]$deployAppScriptParameters = $psBoundParameters
|
||||||
|
|
||||||
|
## Variables: Environment
|
||||||
|
If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
|
||||||
|
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent
|
||||||
|
|
||||||
|
## Dot source the required App Deploy Toolkit Functions
|
||||||
|
Try {
|
||||||
|
[string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
|
||||||
|
If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
|
||||||
|
If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
|
||||||
|
Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: `n$($_.Exception.Message)`n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
|
||||||
|
## Exit the script, returning the exit code to SCCM
|
||||||
|
If (Test-Path -LiteralPath 'variable:HostInvocation') { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
##* Do not modify section above
|
||||||
|
##*===============================================
|
||||||
|
##* END VARIABLE DECLARATION
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
If ($deploymentType -ine 'Uninstall') {
|
||||||
|
##*===============================================
|
||||||
|
##* PRE-INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Pre-Installation'
|
||||||
|
|
||||||
|
Write-Log "Closing related processses"
|
||||||
|
Show-InstallationWelcome -CloseApps 'BioRadC1000Server, BioRadCFXManager, BioRADMiniOpticonDiscovery'
|
||||||
|
|
||||||
|
## Show Progress Message (with the default message)
|
||||||
|
Show-InstallationProgress
|
||||||
|
|
||||||
|
## <Perform Pre-Installation tasks here>
|
||||||
|
|
||||||
|
## Import the Trusted Certs required for installation. ##
|
||||||
|
|
||||||
|
Copy-File -Path "$dirSupportFiles\*.cer" -Destination 'C:\TEMP\'
|
||||||
|
|
||||||
|
# The following only works on W10, so I left it for futue reference #
|
||||||
|
|
||||||
|
#Import-Certificate "C:\TEMP\BioRad.cer" -CertStoreLocation Cert:\LocalMachine\TrustedPublisher\
|
||||||
|
|
||||||
|
#Import-Certificate "C:\TEMP\Jungo.cer" -CertStoreLocation Cert:\LocalMachine\TrustedPublisher\
|
||||||
|
|
||||||
|
certutil -addstore "TrustedPublisher" C:\TEMP\BioRad.cer
|
||||||
|
|
||||||
|
certutil -addstore "TrustedPublisher" C:\TEMP\Jungo.cer
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Installation'
|
||||||
|
|
||||||
|
## Handle Zero-Config MSI Installations
|
||||||
|
If ($useDefaultMsi) {
|
||||||
|
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Install'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
|
||||||
|
Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ } }
|
||||||
|
}
|
||||||
|
|
||||||
|
## <Perform Installation tasks here>
|
||||||
|
|
||||||
|
Write-Log "Installing Bio-Rad CFX Maestro 2.3"
|
||||||
|
Execute-Process -Path "$dirFiles\CFX\CFXMaestroSetup.exe" -Parameters '/S /v/qn'
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* POST-INSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Post-Installation'
|
||||||
|
|
||||||
|
## <Perform Post-Installation tasks here>
|
||||||
|
|
||||||
|
## Remove the Certificates that were copied locally for import.
|
||||||
|
|
||||||
|
Remove-Item 'C:\TEMP' -Recurse
|
||||||
|
|
||||||
|
}
|
||||||
|
ElseIf ($deploymentType -ieq 'Uninstall')
|
||||||
|
{
|
||||||
|
##*===============================================
|
||||||
|
##* PRE-UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Pre-Uninstallation'
|
||||||
|
|
||||||
|
## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
|
||||||
|
Show-InstallationWelcome -CloseApps 'BioRadC1000Server, BioRadCFXManager, BioRADMiniOpticonDiscovery' -CloseAppsCountdown 60
|
||||||
|
|
||||||
|
## Show Progress Message (with the default message)
|
||||||
|
Show-InstallationProgress
|
||||||
|
|
||||||
|
## <Perform Pre-Uninstallation tasks here>
|
||||||
|
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Uninstallation'
|
||||||
|
|
||||||
|
## Handle Zero-Config MSI Uninstallations
|
||||||
|
If ($useDefaultMsi) {
|
||||||
|
[hashtable]$ExecuteDefaultMSISplat = @{ Action = 'Uninstall'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
|
||||||
|
Execute-MSI @ExecuteDefaultMSISplat
|
||||||
|
}
|
||||||
|
|
||||||
|
# <Perform Uninstallation tasks here>
|
||||||
|
|
||||||
|
#Removing CFX Maestro
|
||||||
|
Write-Log "Removing CFX Maestro."
|
||||||
|
Remove-MSIApplications -Name 'Maestro' -FilterApplication (,('Publisher', 'Bio-Rad Laboratories, Inc.', 'Exact'))
|
||||||
|
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* POST-UNINSTALLATION
|
||||||
|
##*===============================================
|
||||||
|
[string]$installPhase = 'Post-Uninstallation'
|
||||||
|
|
||||||
|
## <Perform Post-Uninstallation tasks here>
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
##*===============================================
|
||||||
|
##* END SCRIPT BODY
|
||||||
|
##*===============================================
|
||||||
|
|
||||||
|
## Call the Exit-Script function to perform final cleanup operations
|
||||||
|
Exit-Script -ExitCode $mainExitCode
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
[int32]$mainExitCode = 60001
|
||||||
|
[string]$mainErrorMessage = "$(Resolve-Error)"
|
||||||
|
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
|
||||||
|
Show-DialogBox -Text $mainErrorMessage -Icon 'Stop'
|
||||||
|
Exit-Script -ExitCode $mainExitCode
|
||||||
|
}
|
||||||
BIN
CFX Maestro/2.3/PS_Deployment.old/Files/CFX Eula 10-11-23.docx
Normal file
BIN
CFX Maestro/2.3/PS_Deployment.old/Files/CFX Eula 10-11-23.docx
Normal file
Binary file not shown.
BIN
CFX Maestro/2.3/PS_Deployment.old/Files/CFX Maestro EULA.pdf
Normal file
BIN
CFX Maestro/2.3/PS_Deployment.old/Files/CFX Maestro EULA.pdf
Normal file
Binary file not shown.
100042
CFX Maestro/2.3/PS_Deployment.old/Files/CFX Maestro Release Notes.rtf
Normal file
100042
CFX Maestro/2.3/PS_Deployment.old/Files/CFX Maestro Release Notes.rtf
Normal file
File diff suppressed because it is too large
Load Diff
BIN
CFX Maestro/2.3/PS_Deployment.old/Files/CFX/CFXMaestroSetup.exe
Normal file
BIN
CFX Maestro/2.3/PS_Deployment.old/Files/CFX/CFXMaestroSetup.exe
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,170 @@
|
|||||||
|
; Jungo Confidential. Copyright (c) 2010 Jungo. http://www.jungo.com
|
||||||
|
; Generated by DriverWizard v10.10.
|
||||||
|
; Installation file (.inf) for "C1000 Flagship" device
|
||||||
|
; Installation file (.inf) for "S1000 Satellite" device
|
||||||
|
; Installation file (.inf) for "Mini Cycler" device
|
||||||
|
; Copyright (c) 2010 Bio-Rad Laboratories
|
||||||
|
;
|
||||||
|
;
|
||||||
|
; Refer to Windows DDK documentation for more information on INF files
|
||||||
|
******************** Modified 2 Sept 2011 CLusher **************************
|
||||||
|
; Added cypress unprogrammed vid/pid to the jungo list of devices
|
||||||
|
******************** Modified 28 Mar 2011 STaran **************************
|
||||||
|
; Changed name to CFX Connect Thermal Cycler
|
||||||
|
;******************** Modified 29 Dec 2010 STaran **************************
|
||||||
|
; Added new CFX2 Thermal Cycler
|
||||||
|
;******************** Modified 8 Nov 2010 CLusher **************************
|
||||||
|
; Jungo 10.21
|
||||||
|
; ****************************************************************************
|
||||||
|
; ******************** Modified 8 July 2010 STaran **************************
|
||||||
|
; Updated CatalogFile to reference new Jungo version 10.20
|
||||||
|
; ****************************************************************************
|
||||||
|
; ******************** Modified 8 July 2010 CLusher **************************
|
||||||
|
; added c1000 touch vid/pid
|
||||||
|
; ****************************************************************************
|
||||||
|
; ******************** Modified 12 Jan 2010 CLusher **************************
|
||||||
|
; Updated to Jungo 10.1
|
||||||
|
; Removed Win98/ME Install lines
|
||||||
|
; ****************************************************************************
|
||||||
|
; ******************** Modified 24 Jul 2007 MRegalia *************************
|
||||||
|
; Removed windrvr6.sys from FilesToCopy section and added wdapi900.dll to be
|
||||||
|
; copied to the %windir%\System32 directory.
|
||||||
|
;
|
||||||
|
; Removed windrvr6.sys from the SourceDisksFiles section and added wdapi900.dll
|
||||||
|
;
|
||||||
|
; Removed DefaultDestDir=10 reference.
|
||||||
|
; *****************************************************************************
|
||||||
|
; ******************** Modified 25 Jul 2007 MRegalia **************************
|
||||||
|
; Changed inf file name from BR_Satellite.inf to C1000_ThermalCycler.inf
|
||||||
|
;
|
||||||
|
; Change device list names to C1000 Thermal Cycler and S1000 Thermal Cycler.
|
||||||
|
; Remove Flagship and Satellite references.
|
||||||
|
;
|
||||||
|
; Remove copy wdapi900.dll to the %windir%\System32 directory. File is not copied
|
||||||
|
; until the device is connected. This prevents application from running without
|
||||||
|
; device attached at least once.
|
||||||
|
; *****************************************************************************
|
||||||
|
;
|
||||||
|
; Version Information
|
||||||
|
; -------------------
|
||||||
|
[Version]
|
||||||
|
Signature="$CHICAGO$" ; Represents all Windows OS's
|
||||||
|
Provider=%jun%
|
||||||
|
; For WHQL, you should obtain a catalog signed by Microsoft Hardware Compatibility Labs
|
||||||
|
CatalogFile=c1000.cat
|
||||||
|
DriverVer=01/07/2013, 11.2.0
|
||||||
|
|
||||||
|
; Select an appropriate class for the device.
|
||||||
|
; There are several options:
|
||||||
|
; - Use the Jungo class.
|
||||||
|
; - Define your own class by generating a private GUID and a class description.
|
||||||
|
; - Use a system-defined class. This is required for a device that belongs to
|
||||||
|
; a device class that is supported by system-provided drivers, i.e. HID or USB Audio.
|
||||||
|
; For example, to replace a default USB mouse driver you have to specify the
|
||||||
|
; description and GUID of HID class:
|
||||||
|
; Class=HIDClass
|
||||||
|
; ClassGuid={745a17a0-74d3-11d0-b6fe-00a0c90f57da}
|
||||||
|
;
|
||||||
|
; We use a Jungo class, you may modify here and use a different class:
|
||||||
|
Class=Jungo
|
||||||
|
ClassGuid={c671678c-82c1-43f3-d700-0049433e9a4b}
|
||||||
|
|
||||||
|
; Driver Information
|
||||||
|
; ------------------
|
||||||
|
[Manufacturer]
|
||||||
|
; You may modify the manufacturer name by changing the Mfg variable in the [Strings]
|
||||||
|
; section in this INF file.
|
||||||
|
%Mfg%=DeviceList,NTamd64
|
||||||
|
|
||||||
|
; The 'Install' lines under the [DeviceList] include the device name that will
|
||||||
|
; be displayed in the Device Managerand the hardware ID's.
|
||||||
|
; You may modify the device names and the hardware ID's.
|
||||||
|
; The Vendor ID is 0614, and the Product ID is 03fb
|
||||||
|
|
||||||
|
; x86 platform, Win9x, Windows 2000 and later
|
||||||
|
[DeviceList]
|
||||||
|
"C1000 Touch Thermal Cycler"=Install, USB\VID_0614&PID_057B
|
||||||
|
"C1000 Thermal Cycler"=Install, USB\VID_0614&PID_03FA
|
||||||
|
"CFX Connect Thermal Cycler"=Install, USB\VID_0614&PID_057D
|
||||||
|
"S1000 Thermal Cycler"=Install, USB\VID_0614&PID_03FB
|
||||||
|
"Bio-Rad Mini Cycler"=Install,USB\VID_4079&PID_0221
|
||||||
|
"Bio-Rad Mini Optical Module"=Install,USB\VID_4079&PID_0222
|
||||||
|
"Bio-Rad Mini Cycler UnProgrammed"=Install,USB\VID_0547&PID_2131
|
||||||
|
"Bio-Rad Locust Thermal Module"=Install,USB\VID_0614&PID_1410
|
||||||
|
"Bio-Rad Locust Optics Module"=Install,USB\VID_0614&PID_1411
|
||||||
|
|
||||||
|
; x64 platform, Windows XP x64 edition and later
|
||||||
|
[DeviceList.NTamd64]
|
||||||
|
"C1000 Touch Thermal Cycler"=Install, USB\VID_0614&PID_057B
|
||||||
|
"C1000 Thermal Cycler"=Install, USB\VID_0614&PID_03FA
|
||||||
|
"CFX Connect Thermal Cycler"=Install, USB\VID_0614&PID_057D
|
||||||
|
"S1000 Thermal Cycler"=Install, USB\VID_0614&PID_03FB
|
||||||
|
"Bio-Rad Mini Cycler"=Install,USB\VID_4079&PID_0221
|
||||||
|
"Bio-Rad Mini Optical Module"=Install,USB\VID_4079&PID_0222
|
||||||
|
"Bio-Rad Mini Cycler UnProgrammed"=Install,USB\VID_0547&PID_2131
|
||||||
|
"Bio-Rad Locust Thermal Module"=Install,USB\VID_0614&PID_1410
|
||||||
|
"Bio-Rad Locust Optics Module"=Install,USB\VID_0614&PID_1411
|
||||||
|
|
||||||
|
; Installation Section
|
||||||
|
; --------------------
|
||||||
|
[Install.NT] ; Installation script for Windows 2000 and later
|
||||||
|
CopyFiles=FilesToCopy
|
||||||
|
AddReg=UpDateRegistry
|
||||||
|
|
||||||
|
[FilesToCopy]
|
||||||
|
; To copy windrvr6.sys upon installation remove the ';' from the start of the following line
|
||||||
|
;windrvr6.sys ,,,0x40 ; 0x40 == COPYFLG_OVERWRITE_OLDER_ONLY
|
||||||
|
|
||||||
|
[ClassInstall32] ; Register a new class in Windows 2000 and later
|
||||||
|
AddReg=UpDateRegistry
|
||||||
|
|
||||||
|
[UpDateRegistry]
|
||||||
|
HKR,,,,Jungo
|
||||||
|
HKR,,Icon,,-5
|
||||||
|
HKR,,DevLoader,,*ntkern
|
||||||
|
HKR,,NTMPDriver,, windrvr6.sys
|
||||||
|
|
||||||
|
[ControlFlags]
|
||||||
|
ExcludeFromSelect = * ; Remove all devices listed in this INF file from certain user
|
||||||
|
; interface displays, from which a user is expected to select a particular device
|
||||||
|
; for installation.
|
||||||
|
|
||||||
|
[PreCopySection]
|
||||||
|
HKR,,NoSetupUI,,1
|
||||||
|
|
||||||
|
; Defining WinDriver6 Service
|
||||||
|
; ---------------------------
|
||||||
|
[Install.NT.Services]
|
||||||
|
Addservice=WinDriver6, 0x00000002, Service_Info
|
||||||
|
|
||||||
|
[Service_Info]
|
||||||
|
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
|
||||||
|
StartType = 3 ; SERVICE_DEMAND_START
|
||||||
|
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
|
||||||
|
ServiceBinary = %10%\System32\Drivers\windrvr6.sys
|
||||||
|
|
||||||
|
; Source File Information
|
||||||
|
; -----------------------
|
||||||
|
[SourceDisksFiles]
|
||||||
|
;windrvr6.sys=1 ; This indicates that the windrvr6.sys file is located on
|
||||||
|
; disk number 1 of "Bio-Rad Laboratories Installation disks" set.
|
||||||
|
;wdapi900.dll=1
|
||||||
|
|
||||||
|
[SourceDisksNames]
|
||||||
|
1="Bio-Rad Laboratories Installation Disk",, ; This indicates that disk number 1
|
||||||
|
; has the label "Bio-Rad Laboratories Installation Disk". The installer will
|
||||||
|
; search for windrvr6.sys in this disk.
|
||||||
|
|
||||||
|
[DestinationDirs]
|
||||||
|
|
||||||
|
;DefaultDestDir=10, System32\Drivers ; The location to which the windrvr6.sys
|
||||||
|
; file will be copied (10 translates to the correct Windows directory
|
||||||
|
; on the target machine).
|
||||||
|
|
||||||
|
|
||||||
|
;---------------------------------------------------------------;
|
||||||
|
|
||||||
|
[Strings]
|
||||||
|
jun="Jungo LTD."
|
||||||
|
Mfg="Bio-Rad Laboratories"
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
attrib -r ..\..\..\bioradEV*.dll
|
||||||
|
attrib -r ..\..\..\bioradMini*.dll
|
||||||
|
attrib -r ..\..\..\bioradSi*.dll
|
||||||
|
Copy BioRad*.dll ..\..\..
|
||||||
|
attrib -r ..\..\..\wdapi*.dll
|
||||||
|
Copy wdapi*.dll ..\..\..
|
||||||
|
copy InstallType.txt ..
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Copy BioRad*.dll ..\..\..
|
||||||
|
attrib -r ..\..\..\wdapi*.dll
|
||||||
|
Copy wdapi*.dll ..\..\..
|
||||||
|
|
||||||
|
call register.bat %1
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
32-Bit
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,15 @@
|
|||||||
|
if "%~1"=="" goto nolog
|
||||||
|
|
||||||
|
echo Registration with log
|
||||||
|
mkdir "%~1"
|
||||||
|
wdreg_GUI -inf windrvr6.inf -log "%~1\windrv6_32.txt" -silent install
|
||||||
|
wdreg_GUI -inf C1000_ThermalCycler.inf -log "%~1\C1000_ThermalCycler_32.txt" -silent install
|
||||||
|
|
||||||
|
goto done
|
||||||
|
|
||||||
|
:nolog
|
||||||
|
echo Registration with no log
|
||||||
|
wdreg_GUI -inf windrvr6.inf -silent install
|
||||||
|
wdreg_GUI -inf C1000_ThermalCycler.inf -silent install
|
||||||
|
|
||||||
|
:done
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
wdreg -inf windrvr6.inf uninstall
|
||||||
|
wdreg -inf C1000_ThermalCycler.inf uninstall
|
||||||
|
|
||||||
|
pause
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,84 @@
|
|||||||
|
;
|
||||||
|
; Jungo Confidential. Copyright (c) 2013 Jungo Ltd. http://www.jungo.com
|
||||||
|
;
|
||||||
|
; Installs windrvr6.sys as a driver for a pseudo-device
|
||||||
|
;
|
||||||
|
|
||||||
|
[Version]
|
||||||
|
Signature=$CHICAGO$
|
||||||
|
Class=Jungo
|
||||||
|
ClassGuid={c671678c-82c1-43f3-d700-0049433e9a4b}
|
||||||
|
Provider=%MFGNAME%
|
||||||
|
; The catalog file below is digitally signed by Jungo.
|
||||||
|
; For WHQL, you should obtain a catalog signed by Microsoft Hardware Compatibility Labs
|
||||||
|
CatalogFile=wd1120.cat
|
||||||
|
DriverVer=01/07/2013, 11.2.0
|
||||||
|
|
||||||
|
[Manufacturer]
|
||||||
|
%MFGNAME%=DeviceList,NTamd64
|
||||||
|
|
||||||
|
[DestinationDirs]
|
||||||
|
DefaultDestDir=10,System32\Drivers
|
||||||
|
|
||||||
|
[SourceDisksFiles]
|
||||||
|
windrvr6.sys=1
|
||||||
|
|
||||||
|
[SourceDisksNames]
|
||||||
|
1=%INSTDISK%,,,.
|
||||||
|
;Delete the above line and uncomment the next line for WHQL
|
||||||
|
;1 = %INSTDISK%,windrvr6.cat,,
|
||||||
|
|
||||||
|
; x86 platform, Win9x, Windows 2000 and later
|
||||||
|
[DeviceList]
|
||||||
|
%DESCRIPTION%=DriverInstall,*WINDRVR6
|
||||||
|
|
||||||
|
; x64 platform, Windows XP x64 edition and later
|
||||||
|
[DeviceList.NTamd64]
|
||||||
|
%DESCRIPTION%=DriverInstall,*WINDRVR6
|
||||||
|
|
||||||
|
[ClassInstall32] ; Register a new class in Windows 2000 and later
|
||||||
|
AddReg=UpdateRegistry
|
||||||
|
|
||||||
|
[UpdateRegistry]
|
||||||
|
HKR,,,,Jungo
|
||||||
|
HKR,,Icon,,-5
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; Windows 2000 and later Sections (x86 and x64 platforms)
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[DriverInstall.NT]
|
||||||
|
CopyFiles=DriverCopyFiles
|
||||||
|
|
||||||
|
[DriverCopyFiles]
|
||||||
|
windrvr6.sys,,,0x22 ; COPYFLG_NOSKIP | COPYFLG_NO_VERSION_DIALOG
|
||||||
|
|
||||||
|
[DriverInstall.NT.Services]
|
||||||
|
AddService=WinDriver6,2,DriverService
|
||||||
|
|
||||||
|
[DriverService]
|
||||||
|
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
|
||||||
|
StartType = 3 ; SERVICE_DEMAND_START
|
||||||
|
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
|
||||||
|
ServiceBinary=%10%\system32\drivers\windrvr6.sys
|
||||||
|
AddReg = windrvr6.AddReg
|
||||||
|
|
||||||
|
[windrvr6.AddReg]
|
||||||
|
;Set the value below to 1 to enable legacy read/write of PCI configuration space
|
||||||
|
HKR, Parameters, PciCfgRwCompat, 0x00010001, 0
|
||||||
|
|
||||||
|
[DriverInstall.NT.hw]
|
||||||
|
AddReg=DriverHwAddReg
|
||||||
|
|
||||||
|
[DriverHwAddReg]
|
||||||
|
HKR,,SampleInfo,,""
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; String Definitions
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[Strings]
|
||||||
|
MFGNAME="Jungo"
|
||||||
|
INSTDISK="Jungo Installation Disc"
|
||||||
|
DESCRIPTION="WinDriver"
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,170 @@
|
|||||||
|
; Jungo Confidential. Copyright (c) 2010 Jungo. http://www.jungo.com
|
||||||
|
; Generated by DriverWizard v10.10.
|
||||||
|
; Installation file (.inf) for "C1000 Flagship" device
|
||||||
|
; Installation file (.inf) for "S1000 Satellite" device
|
||||||
|
; Installation file (.inf) for "Mini Cycler" device
|
||||||
|
; Copyright (c) 2010 Bio-Rad Laboratories
|
||||||
|
;
|
||||||
|
;
|
||||||
|
; Refer to Windows DDK documentation for more information on INF files
|
||||||
|
******************** Modified 2 Sept 2011 CLusher **************************
|
||||||
|
; Added cypress unprogrammed vid/pid to the jungo list of devices
|
||||||
|
******************** Modified 28 Mar 2011 STaran **************************
|
||||||
|
; Changed name to CFX Connect Thermal Cycler
|
||||||
|
;******************** Modified 29 Dec 2010 STaran **************************
|
||||||
|
; Added new CFX2 Thermal Cycler
|
||||||
|
;******************** Modified 8 Nov 2010 CLusher **************************
|
||||||
|
; Jungo 10.21
|
||||||
|
; ****************************************************************************
|
||||||
|
; ******************** Modified 8 July 2010 STaran **************************
|
||||||
|
; Updated CatalogFile to reference new Jungo version 10.20
|
||||||
|
; ****************************************************************************
|
||||||
|
; ******************** Modified 8 July 2010 CLusher **************************
|
||||||
|
; added c1000 touch vid/pid
|
||||||
|
; ****************************************************************************
|
||||||
|
; ******************** Modified 12 Jan 2010 CLusher **************************
|
||||||
|
; Updated to Jungo 10.1
|
||||||
|
; Removed Win98/ME Install lines
|
||||||
|
; ****************************************************************************
|
||||||
|
; ******************** Modified 24 Jul 2007 MRegalia *************************
|
||||||
|
; Removed windrvr6.sys from FilesToCopy section and added wdapi900.dll to be
|
||||||
|
; copied to the %windir%\System32 directory.
|
||||||
|
;
|
||||||
|
; Removed windrvr6.sys from the SourceDisksFiles section and added wdapi900.dll
|
||||||
|
;
|
||||||
|
; Removed DefaultDestDir=10 reference.
|
||||||
|
; *****************************************************************************
|
||||||
|
; ******************** Modified 25 Jul 2007 MRegalia **************************
|
||||||
|
; Changed inf file name from BR_Satellite.inf to C1000_ThermalCycler.inf
|
||||||
|
;
|
||||||
|
; Change device list names to C1000 Thermal Cycler and S1000 Thermal Cycler.
|
||||||
|
; Remove Flagship and Satellite references.
|
||||||
|
;
|
||||||
|
; Remove copy wdapi900.dll to the %windir%\System32 directory. File is not copied
|
||||||
|
; until the device is connected. This prevents application from running without
|
||||||
|
; device attached at least once.
|
||||||
|
; *****************************************************************************
|
||||||
|
;
|
||||||
|
; Version Information
|
||||||
|
; -------------------
|
||||||
|
[Version]
|
||||||
|
Signature="$CHICAGO$" ; Represents all Windows OS's
|
||||||
|
Provider=%jun%
|
||||||
|
; For WHQL, you should obtain a catalog signed by Microsoft Hardware Compatibility Labs
|
||||||
|
CatalogFile=c1000.cat
|
||||||
|
DriverVer=01/07/2013, 11.2.0
|
||||||
|
|
||||||
|
; Select an appropriate class for the device.
|
||||||
|
; There are several options:
|
||||||
|
; - Use the Jungo class.
|
||||||
|
; - Define your own class by generating a private GUID and a class description.
|
||||||
|
; - Use a system-defined class. This is required for a device that belongs to
|
||||||
|
; a device class that is supported by system-provided drivers, i.e. HID or USB Audio.
|
||||||
|
; For example, to replace a default USB mouse driver you have to specify the
|
||||||
|
; description and GUID of HID class:
|
||||||
|
; Class=HIDClass
|
||||||
|
; ClassGuid={745a17a0-74d3-11d0-b6fe-00a0c90f57da}
|
||||||
|
;
|
||||||
|
; We use a Jungo class, you may modify here and use a different class:
|
||||||
|
Class=Jungo
|
||||||
|
ClassGuid={c671678c-82c1-43f3-d700-0049433e9a4b}
|
||||||
|
|
||||||
|
; Driver Information
|
||||||
|
; ------------------
|
||||||
|
[Manufacturer]
|
||||||
|
; You may modify the manufacturer name by changing the Mfg variable in the [Strings]
|
||||||
|
; section in this INF file.
|
||||||
|
%Mfg%=DeviceList,NTamd64
|
||||||
|
|
||||||
|
; The 'Install' lines under the [DeviceList] include the device name that will
|
||||||
|
; be displayed in the Device Managerand the hardware ID's.
|
||||||
|
; You may modify the device names and the hardware ID's.
|
||||||
|
; The Vendor ID is 0614, and the Product ID is 03fb
|
||||||
|
|
||||||
|
; x86 platform, Win9x, Windows 2000 and later
|
||||||
|
[DeviceList]
|
||||||
|
"C1000 Touch Thermal Cycler"=Install, USB\VID_0614&PID_057B
|
||||||
|
"C1000 Thermal Cycler"=Install, USB\VID_0614&PID_03FA
|
||||||
|
"CFX Connect Thermal Cycler"=Install, USB\VID_0614&PID_057D
|
||||||
|
"S1000 Thermal Cycler"=Install, USB\VID_0614&PID_03FB
|
||||||
|
"Bio-Rad Mini Cycler"=Install,USB\VID_4079&PID_0221
|
||||||
|
"Bio-Rad Mini Optical Module"=Install,USB\VID_4079&PID_0222
|
||||||
|
"Bio-Rad Mini Cycler UnProgrammed"=Install,USB\VID_0547&PID_2131
|
||||||
|
"Bio-Rad Locust Thermal Module"=Install,USB\VID_0614&PID_1410
|
||||||
|
"Bio-Rad Locust Optics Module"=Install,USB\VID_0614&PID_1411
|
||||||
|
|
||||||
|
; x64 platform, Windows XP x64 edition and later
|
||||||
|
[DeviceList.NTamd64]
|
||||||
|
"C1000 Touch Thermal Cycler"=Install, USB\VID_0614&PID_057B
|
||||||
|
"C1000 Thermal Cycler"=Install, USB\VID_0614&PID_03FA
|
||||||
|
"CFX Connect Thermal Cycler"=Install, USB\VID_0614&PID_057D
|
||||||
|
"S1000 Thermal Cycler"=Install, USB\VID_0614&PID_03FB
|
||||||
|
"Bio-Rad Mini Cycler"=Install,USB\VID_4079&PID_0221
|
||||||
|
"Bio-Rad Mini Optical Module"=Install,USB\VID_4079&PID_0222
|
||||||
|
"Bio-Rad Mini Cycler UnProgrammed"=Install,USB\VID_0547&PID_2131
|
||||||
|
"Bio-Rad Locust Thermal Module"=Install,USB\VID_0614&PID_1410
|
||||||
|
"Bio-Rad Locust Optics Module"=Install,USB\VID_0614&PID_1411
|
||||||
|
|
||||||
|
; Installation Section
|
||||||
|
; --------------------
|
||||||
|
[Install.NT] ; Installation script for Windows 2000 and later
|
||||||
|
CopyFiles=FilesToCopy
|
||||||
|
AddReg=UpDateRegistry
|
||||||
|
|
||||||
|
[FilesToCopy]
|
||||||
|
; To copy windrvr6.sys upon installation remove the ';' from the start of the following line
|
||||||
|
;windrvr6.sys ,,,0x40 ; 0x40 == COPYFLG_OVERWRITE_OLDER_ONLY
|
||||||
|
|
||||||
|
[ClassInstall32] ; Register a new class in Windows 2000 and later
|
||||||
|
AddReg=UpDateRegistry
|
||||||
|
|
||||||
|
[UpDateRegistry]
|
||||||
|
HKR,,,,Jungo
|
||||||
|
HKR,,Icon,,-5
|
||||||
|
HKR,,DevLoader,,*ntkern
|
||||||
|
HKR,,NTMPDriver,, windrvr6.sys
|
||||||
|
|
||||||
|
[ControlFlags]
|
||||||
|
ExcludeFromSelect = * ; Remove all devices listed in this INF file from certain user
|
||||||
|
; interface displays, from which a user is expected to select a particular device
|
||||||
|
; for installation.
|
||||||
|
|
||||||
|
[PreCopySection]
|
||||||
|
HKR,,NoSetupUI,,1
|
||||||
|
|
||||||
|
; Defining WinDriver6 Service
|
||||||
|
; ---------------------------
|
||||||
|
[Install.NT.Services]
|
||||||
|
Addservice=WinDriver6, 0x00000002, Service_Info
|
||||||
|
|
||||||
|
[Service_Info]
|
||||||
|
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
|
||||||
|
StartType = 3 ; SERVICE_DEMAND_START
|
||||||
|
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
|
||||||
|
ServiceBinary = %10%\System32\Drivers\windrvr6.sys
|
||||||
|
|
||||||
|
; Source File Information
|
||||||
|
; -----------------------
|
||||||
|
[SourceDisksFiles]
|
||||||
|
;windrvr6.sys=1 ; This indicates that the windrvr6.sys file is located on
|
||||||
|
; disk number 1 of "Bio-Rad Laboratories Installation disks" set.
|
||||||
|
;wdapi900.dll=1
|
||||||
|
|
||||||
|
[SourceDisksNames]
|
||||||
|
1="Bio-Rad Laboratories Installation Disk",, ; This indicates that disk number 1
|
||||||
|
; has the label "Bio-Rad Laboratories Installation Disk". The installer will
|
||||||
|
; search for windrvr6.sys in this disk.
|
||||||
|
|
||||||
|
[DestinationDirs]
|
||||||
|
|
||||||
|
;DefaultDestDir=10, System32\Drivers ; The location to which the windrvr6.sys
|
||||||
|
; file will be copied (10 translates to the correct Windows directory
|
||||||
|
; on the target machine).
|
||||||
|
|
||||||
|
|
||||||
|
;---------------------------------------------------------------;
|
||||||
|
|
||||||
|
[Strings]
|
||||||
|
jun="Jungo LTD."
|
||||||
|
Mfg="Bio-Rad Laboratories"
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
attrib -r ..\..\..\bioradEV*.dll
|
||||||
|
attrib -r ..\..\..\bioradMini*.dll
|
||||||
|
attrib -r ..\..\..\bioradSi*.dll
|
||||||
|
Copy BioRad*.dll ..\..\..
|
||||||
|
attrib -r ..\..\..\wdapi*.dll
|
||||||
|
Copy wdapi*.dll ..\..\..
|
||||||
|
copy InstallType.txt ..
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Copy BioRad*.dll ..\..\..
|
||||||
|
attrib -r ..\..\..\wdapi*.dll
|
||||||
|
Copy wdapi*.dll ..\..\..
|
||||||
|
|
||||||
|
call register.bat %1
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
64-Bit
|
||||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
|||||||
|
if "%~1"=="" goto nolog
|
||||||
|
|
||||||
|
echo Registration with log
|
||||||
|
mkdir "%~1"
|
||||||
|
wdreg_GUI -inf windrvr6.inf -log "%~1\windrv6_64.txt" -silent install
|
||||||
|
wdreg_GUI -inf C1000_ThermalCycler.inf -log "%~1\C1000_ThermalCycler_64.txt" -silent install
|
||||||
|
|
||||||
|
goto done
|
||||||
|
|
||||||
|
:nolog
|
||||||
|
echo Registration with no log
|
||||||
|
wdreg_GUI -inf windrvr6.inf -silent install
|
||||||
|
wdreg_GUI -inf C1000_ThermalCycler.inf -silent install
|
||||||
|
|
||||||
|
:done
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
wdreg -inf windrvr6.inf uninstall
|
||||||
|
wdreg -inf C1000_ThermalCycler.inf uninstall
|
||||||
|
|
||||||
|
pause
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,84 @@
|
|||||||
|
;
|
||||||
|
; Jungo Confidential. Copyright (c) 2013 Jungo Ltd. http://www.jungo.com
|
||||||
|
;
|
||||||
|
; Installs windrvr6.sys as a driver for a pseudo-device
|
||||||
|
;
|
||||||
|
|
||||||
|
[Version]
|
||||||
|
Signature=$CHICAGO$
|
||||||
|
Class=Jungo
|
||||||
|
ClassGuid={c671678c-82c1-43f3-d700-0049433e9a4b}
|
||||||
|
Provider=%MFGNAME%
|
||||||
|
; The catalog file below is digitally signed by Jungo.
|
||||||
|
; For WHQL, you should obtain a catalog signed by Microsoft Hardware Compatibility Labs
|
||||||
|
CatalogFile=wd1120.cat
|
||||||
|
DriverVer=01/07/2013, 11.2.0
|
||||||
|
|
||||||
|
[Manufacturer]
|
||||||
|
%MFGNAME%=DeviceList,NTamd64
|
||||||
|
|
||||||
|
[DestinationDirs]
|
||||||
|
DefaultDestDir=10,System32\Drivers
|
||||||
|
|
||||||
|
[SourceDisksFiles]
|
||||||
|
windrvr6.sys=1
|
||||||
|
|
||||||
|
[SourceDisksNames]
|
||||||
|
1=%INSTDISK%,,,.
|
||||||
|
;Delete the above line and uncomment the next line for WHQL
|
||||||
|
;1 = %INSTDISK%,windrvr6.cat,,
|
||||||
|
|
||||||
|
; x86 platform, Win9x, Windows 2000 and later
|
||||||
|
[DeviceList]
|
||||||
|
%DESCRIPTION%=DriverInstall,*WINDRVR6
|
||||||
|
|
||||||
|
; x64 platform, Windows XP x64 edition and later
|
||||||
|
[DeviceList.NTamd64]
|
||||||
|
%DESCRIPTION%=DriverInstall,*WINDRVR6
|
||||||
|
|
||||||
|
[ClassInstall32] ; Register a new class in Windows 2000 and later
|
||||||
|
AddReg=UpdateRegistry
|
||||||
|
|
||||||
|
[UpdateRegistry]
|
||||||
|
HKR,,,,Jungo
|
||||||
|
HKR,,Icon,,-5
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; Windows 2000 and later Sections (x86 and x64 platforms)
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[DriverInstall.NT]
|
||||||
|
CopyFiles=DriverCopyFiles
|
||||||
|
|
||||||
|
[DriverCopyFiles]
|
||||||
|
windrvr6.sys,,,0x22 ; COPYFLG_NOSKIP | COPYFLG_NO_VERSION_DIALOG
|
||||||
|
|
||||||
|
[DriverInstall.NT.Services]
|
||||||
|
AddService=WinDriver6,2,DriverService
|
||||||
|
|
||||||
|
[DriverService]
|
||||||
|
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
|
||||||
|
StartType = 3 ; SERVICE_DEMAND_START
|
||||||
|
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
|
||||||
|
ServiceBinary=%10%\system32\drivers\windrvr6.sys
|
||||||
|
AddReg = windrvr6.AddReg
|
||||||
|
|
||||||
|
[windrvr6.AddReg]
|
||||||
|
;Set the value below to 1 to enable legacy read/write of PCI configuration space
|
||||||
|
HKR, Parameters, PciCfgRwCompat, 0x00010001, 0
|
||||||
|
|
||||||
|
[DriverInstall.NT.hw]
|
||||||
|
AddReg=DriverHwAddReg
|
||||||
|
|
||||||
|
[DriverHwAddReg]
|
||||||
|
HKR,,SampleInfo,,""
|
||||||
|
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
; String Definitions
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[Strings]
|
||||||
|
MFGNAME="Jungo"
|
||||||
|
INSTDISK="Jungo Installation Disc"
|
||||||
|
DESCRIPTION="WinDriver"
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,57 @@
|
|||||||
|
a) signed 2 cat files in \files folder with 2023 biorad certificate
|
||||||
|
(This may not be absolutely required, as FTDI has there two cat files signed already)
|
||||||
|
|
||||||
|
Please note:
|
||||||
|
- Make sure .cat file are not read-only before issuing the following command
|
||||||
|
- replace /p ... with actual password below
|
||||||
|
|
||||||
|
signtool.exe sign /fd sha256 /a /f "current LSGRD CS.pfx" /p 6P...7D /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td sha256 /v ..\files\*.cat
|
||||||
|
The following certificate was selected:
|
||||||
|
Issued to: Bio-Rad Laboratories, Inc
|
||||||
|
Issued by: Symantec Class 3 SHA256 Code Signing CA
|
||||||
|
Expires: Thu Mar 09 16:59:59 2023
|
||||||
|
SHA1 hash: 8311FE0202D3634C444BDB2EA696369667725015
|
||||||
|
|
||||||
|
Done Adding Additional Store
|
||||||
|
Successfully signed: ..\files\ftdibus.cat
|
||||||
|
Successfully signed: ..\files\ftdiport.cat
|
||||||
|
|
||||||
|
Number of files successfully Signed: 2
|
||||||
|
Number of warnings: 0
|
||||||
|
Number of errors: 0
|
||||||
|
|
||||||
|
b) Removed dpinst.xml so driver can be installed in silent mode
|
||||||
|
|
||||||
|
Can now run the 64-Bit version:
|
||||||
|
dpinst-amd64.exe /S /C
|
||||||
|
where: /S is for silent
|
||||||
|
/C reports any errors with is very helpful for troubleshooting problems
|
||||||
|
|
||||||
|
|
||||||
|
See that it installs two FTDI entries under:
|
||||||
|
Control Panel\All Control Panel Items\Programs and Features
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
To remove the FTDI driver use CDMuninstallerGUI.exe utility
|
||||||
|
Start it,
|
||||||
|
clear product ID field
|
||||||
|
Click ADD
|
||||||
|
click [x] generate uninstall log
|
||||||
|
then click remove devices
|
||||||
|
|
||||||
|
|
||||||
|
The log will show something like this:
|
||||||
|
Searching DriverStore
|
||||||
|
Search concluded after finding no results matching VID_0403 and PID_.
|
||||||
|
Deleting INF Files
|
||||||
|
pnputil.exe /f /d oem105.inf298
|
||||||
|
Successfully removed.pnputil.exe /f /d oem106.inf0
|
||||||
|
Successfully removed.Done
|
||||||
|
Searching DriverStore
|
||||||
|
Search concluded after finding no results matching VID_0403 and PID_.
|
||||||
|
Deleting INF Files
|
||||||
|
Done
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user