Skip to content

Instantly share code, notes, and snippets.

View mkht's full-sized avatar

mkht

  • Japan
  • 09:28 (UTC +09:00)
View GitHub Profile
@mkht
mkht / wua.js
Last active July 20, 2017 05:36
Show Windows Update History (WSH JScript version)
function CRun(){
if (!(/CSCRIPT\.EXE/i).test(WScript.FullName)){
var WshShell = new ActiveXObject("WScript.Shell");
var strParam = "";
for (var i = 0; i < WScript.Arguments.Count(); i++){
strParam += " \"" + WScript.Arguments(i).replace("\"", "\"\"") + "\"";
}
WScript.Quit(WshShell.Run("cmd.exe /v:on /s /c \"cscript.exe //nologo \""
+ WScript.ScriptFullName + "\""
+ strParam + " & pause & exit /b !ERRORLEVEL!\"", 8, true));
@mkht
mkht / Get-UpdateHistory.ps1
Last active April 17, 2019 14:21
Show Windows Update History (PowerShell version)
[CmdletBinding()]
Param(
[datetime]$DateTo,
[datetime]$DateFrom,
[switch]$All
)
# 日本語文字化け対策
$Global:OutputEncoding = [Console]::OutputEncoding
@mkht
mkht / LayoutModification.xml
Created October 13, 2017 15:28
Windows10用スタートメニューレイアウト
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" StartTileGroupsColumnCount="1" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6">
<start:Group Name="ブラウザ">
<start:DesktopApplicationTile Size="2x2" Column="0" Row="0" DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\Accessories\Internet Explorer.lnk" />
<start:Tile Size="2x2" Column="2" Row="0" AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" />
<start:DesktopApplicationTile Size="2x2" Column="0" Row="2" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Google Chrome.lnk" />
<start:DesktopApplicationTile Size="2x2" Column="2" Row=
@mkht
mkht / LayoutModification_taskbar.xml
Created October 13, 2017 15:29
Windows10用スタートメニューレイアウト(タスクバーレイアウト付き)
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout">
<LayoutOptions StartTileGroupCellWidth="6" StartTileGroupsColumnCount="1" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6">
<start:Group Name="ブラウザ">
<start:DesktopApplicationTile Size="2x2" Column="0" Row="0" DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\Accessories\Internet Explorer.lnk" />
<start:Tile Size="2x2" Column="2" Row="0" AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" />
<start:DesktopApplicationTile Size="2x2" Column="0" Row="2" DesktopApplicationLinkPath="%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Google Chrome.lnk"
@mkht
mkht / gist:f4fde36c633c6c68278180e3e66261e7
Created November 27, 2017 12:57
Photoshopの関連付けを64bit版に直すスクリプト
$PS32 = 'C:\Program Files (x86)\Adobe\Adobe Photoshop CC 2018 (32 Bit)\Photoshop.exe'
$PS64 = 'C:\Program Files\Adobe\Adobe Photoshop CC 2018\Photoshop.exe'
gci HKLM:\SOFTWARE\Classes | ? {$_.Name -match 'Photoshop'} | gci -Recurse | gp | ? {$_.'(default)'.contains($PS32)} | % { sp -Path $_.PSPath -Name '(default)' -Value $_.'(default)'.Replace($PS32,$PS64)}
@mkht
mkht / AccessorClass.ps1
Created January 18, 2018 15:21
PowerShell class accessor
# Original code
# https://stackoverflow.com/questions/39717230/powershell-class-implement-get-set-property
# This technique is so impressive!
class c {
hidden $_p = $($this | Add-Member ScriptProperty 'p' `
{
# get
"getter $($this._p)"
}`
{
@mkht
mkht / Add-EnvironmentPath.ps1
Created July 18, 2018 13:48
環境変数PATHの末尾に指定の値を追加する
<# ++++++++++++++++++++++++++++++++++++++++++++++
環境変数PATHの末尾に指定の値を追加する
+++++++++++++++++++++++++++++++++++++++++++++++++ #>
function Add-EnvironmentPath {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true, Position = 0)]
[string] $Path, # 追加する値
[Parameter(Mandatory = $true, Position = 1)]
@mkht
mkht / Remove-EnvironmentPath.ps1
Created July 18, 2018 13:49
環境変数PATHから指定の値を削除する
<# ++++++++++++++++++++++++++++++++++++++++++++++
環境変数PATHから指定の値を削除する
+++++++++++++++++++++++++++++++++++++++++++++++++ #>
function Remove-EnvironmentPath {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true, Position = 0)]
[string] $Path, # 削除する値
[Parameter(Mandatory = $true, Position = 1)]
@mkht
mkht / publish.ps1
Last active September 5, 2018 12:01
Publish script for PowerShell Gallery
Param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$NugetApiKey,
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[string[]]$ExcludeDirs = @('.git', '.vscode'),
[Parameter(Mandatory = $false)]
<# =======================================================
ストアアプリ再登録スクリプト 2019/07/12
for Windows 10 64bit Version 1809
======================================================= #>
$ErrorActionPreference = 'Continue'
$ProgressPreference = 'SilentlyContinue'
# Get all apps list
$Apps = Get-AppxPackage -ErrorAction Stop