uwp:如何使用Powershell為windows 10 Universal應用程式建立桌面快捷方式?

參考網址:Codebug

用powershell 為makecode app 建立捷徑
 

$TargetPath =  "shell:AppsFolder\MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar!App"
$ShortcutFile = "$Home\Desktop\MakeCodeAPP.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetPath
$Shortcut.Save()

 

get-appxpackage > d:\application_list.txt 可以得到 APP名稱列表
 

Name              : MicrobitEducationalFounda.196216C47839B
Publisher         : CN=DA0852B7-E38D-4F10-9429-7A96575322FD
Architecture      : X64
ResourceId        : 
Version           : 1.1.0.0
PackageFullName   : MicrobitEducationalFounda.196216C47839B_1.1.0.0_x64__e88r6s0b2swar
InstallLocation   : C:\Program Files\WindowsApps\MicrobitEducationalFounda.196216C47839B_1.1.0.0_x64__e88r6s0b2swar
IsFramework       : False
PackageFamilyName : MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar
PublisherId       : e88r6s0b2swar
IsResourcePackage : False
IsBundle          : False
IsDevelopmentMode : False
NonRemovable      : False
IsPartiallyStaged : False
SignatureKind     : Store
Status            : Ok

找到PackageFamilyName : MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar 在後面加上「!App」

發表於 Windows系統 | 發表迴響

[windows]建立捷徑的bat檔CreateShortcut.bat

@ECHO OFF
TITLE 建立 Xshell & Xftp 捷徑
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Xshell6Portable.lnk""):b.TargetPath=""%~dp0Xshell6Portable.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")
mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Xftp6Portable.lnk""):b.TargetPath=""%~dp0Xftp6Portable.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")
echo Xshell & Xftp 捷徑已建立
pause

這個檔案必需存成bat檔才能正常執行,複製到CMD的環境執行會發生問題(%~dp0  會發生錯誤)。

快閃人生 【批次檔】%CD% 與 %~dp0

%CD%:Current Directory, 當前工作目錄位置
%~dp0:批次檔存在的目錄位置
關於%~dp0其實是%0參數的衍伸用法(可以使用CALL /?查閱詳細說明)
首先執行下面例子先看看結果:
 


@ECHO OFF
CLS

ECHO %%0 = %0
ECHO %%~d0 = %~d0
ECHO %%~p0 = %~p0
ECHO %%~n0 = %~n0
ECHO %%~x0 = %~x0

CALL /?的說明頁面中, 得知在參數%n(%0, %1, … %9)之間加了波浪符號(~)與相關的修飾字詞後, 就會有擴充的支援。
 

  1. %0:第0個參數, 表示批次檔本身。
  2. %~d0:Dirver, 批次檔存在的磁碟機代號。
  3. %~p0:Path, 批次檔的路徑位置(不包含磁碟機代號)。
  4. %~n0:批次檔的檔案名稱。
  5. %~x0:批次檔的副檔名。
  6. 所有的修飾字詞可以混搭使用, 所以%~dp0即是批次檔所在的完整路徑。
  7. 修飾字詞還有~f, ~a, …等, 請參考程式說明頁面。
發表於 Windows系統 | 發表迴響

[portablesoft]綠色便攜軟件

參考網址:https://www.portablesoft.org/

發表於 Windows系統, 軟體使用 | 發表迴響

分辨 Linux 系統是 32 位元還是 64 位元的方法

參考網址:GTW

uname -m

如果是 32 位元的系統,就會顯示 i686 或 i386,而如果是 64 位元的系統就會顯示 x86_64

發表於 Linux系統 | 發表迴響

[tello]DJI Tello 開箱.迷你空拍機

參考網址:http://www.cg.com.tw/DJITello/

發表於 程式設計 | 發表迴響

[碁峯]gotop書籍範例下載

網址:http://books.gotop.com.tw/download/AEZ020100

Scratch 3.0 多媒體遊戲設計 & Tello無人機  http://gogo123.com.tw/?page_id=10787
https://gogo123.com.tw/scratch-3-0/

 

發表於 程式設計, 軟體使用 | 發表迴響

VirtualBox虛擬機 Ubuntu解析度太小的解決方案

參考網址:

https://kknews.cc/zh-tw/code/rygrn8o.html

裝置->插入Guest Additions CD 映像檔
cd /media
執行./VBboxLinuxAdditions.run
重啟後 進入系統設定螢幕解析度

發表於 Linux系統, Windows系統 | 發表迴響

[ubuntu]在 Ubuntu 18.04.1 的 IBus 上安裝大易輸入法

參考網址:https://github.com/Alger23/ubuntu_dayi_for_ibus

下載安裝腳本
$ wget https://raw.githubusercontent.com/Alger23/ubuntu_dayi_for_ibus/master/dayisetup.sh

下載大易三碼字根檔
$ wget https://raw.githubusercontent.com/Alger23/ubuntu_dayi_for_ibus/master/dayi3.cin

執行安裝腳本
$ chmod u+x dayisetup.sh
$ sudo ./dayisetup.sh

 

發表於 Linux系統 | 發表迴響

[PowerShell][Proxy]用PowerShell設定Proxy 完成版

參考網址:https://github.com/majkinetor/posh/blob/master/MM_Network/Update-Proxy.ps1

# Author: Miodrag Milic <miodrag.milic@gmail.com>
# Last Change: 14-Aug-2015.

#requires -version 2.0

<#
.SYNOPSIS
    Get or set system proxy properties.
.DESCRIPTION
    This function implements unified method to set proxy system wide settings.
    It sets both WinINET ("Internet Options" proxy) and WinHTTP proxy.
    Without any arguments function will return the current proxy properties.
    To change a proxy property pass adequate argument to the function.
.EXAMPLE
    Update-Proxy -Server "myproxy.mydomain.com:8080" -Override "" -ShowGUI
    Set proxy server, clear overrides and show IE GUI.
.EXAMPLE
    Update-Proxy | Export-CSV proxy;  Import-CSV proxy | Update-Proxy -Verbose
    Save and restore proxy properties
.EXAMPLE
    $p = Update-Proxy; $p.Override += $p.Override += "*.domain.com" ; $p | proxy
    Add "*.domain.com" to the proxy override list
.NOTES
    The format of the parameters is the same as seen in Internet Options GUI.
    To bypass proxy for a local network specify keyword ";<local>" at the end
    of the Overide values.
    Setting the winhttp proxy requires administrative prvilegies.
.OUTPUTS
    [HashTable]
#>
function Update-Proxy() {
    [CmdletBinding()]
    param(
        # Proxy:Port
        [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
        [string] $Server,
        # Semicollon delimited list of exlusions
        [Parameter(ValueFromPipelineByPropertyName=$true)]
        [string] $Override,
        # 0 to disable, anything else to enable proxy
        [Parameter(ValueFromPipelineByPropertyName=$true)]
        [string] $Enable,
        # Show Internet Options GUI
        [switch] $ShowGUI
    )
    $key  = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
    $r = gp $key
    Write-Verbose "Reading proxy data from the registry"
    $proxy=@{
            Server   = if ($PSBoundParameters.Keys -contains 'Server')   {$Server}   else { $r.ProxyServer }
            Override = if ($PSBoundParameters.Keys -contains 'Override') {$Override} else { $r.ProxyOverride }
            Enable   = if ($PSBoundParameters.Keys -contains 'Enable')   {$Enable}   else { $r.ProxyEnable }
    }

    $set  = "Server","Override","Enable" | ? {$PSBoundParameters.Keys -contains $_ }
    if ($set) {
        #if (!(test-admin)) { throw "Setting proxy requires admin privileges" }

        Write-Verbose "Saving proxy data to registry"

        sp $key ProxyServer   $proxy.Server
        sp $key ProxyOverride $proxy.Override
        sp $key ProxyEnable   $proxy.Enable
        if (!(refresh-system)) { Write-Warning "Can not force system refresh after proxy change" }

        Write-Verbose "Importing winhttp proxy from IE settings"
        $OFS = "`n"
        [string]$res = netsh.exe winhttp import proxy source=ie
        if ($res -match 'Access is denied') {Write-Warning $res}
        else { Write-Verbose $res.Trim()}
    }

    New-Object PSCustomObject -Property $proxy
    if ($ShowGUI) { start control "inetcpl.cpl,,4" }
}

# The registry changes aren't seen until system is notified about it.
# Without this function you need to open Internet Settings window for changes to take effect. See http://goo.gl/OIQ4W4
function refresh-system() {
    $signature = @'
[DllImport("wininet.dll", SetLastError = true, CharSet=CharSet.Auto)]
public static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int dwBufferLength);
'@

    $INTERNET_OPTION_SETTINGS_CHANGED   = 39
    $INTERNET_OPTION_REFRESH            = 37
    $type = Add-Type -MemberDefinition $signature -Name wininet -Namespace pinvoke -PassThru
    $a = $type::InternetSetOption(0, $INTERNET_OPTION_SETTINGS_CHANGED, 0, 0)
    $b = $type::InternetSetOption(0, $INTERNET_OPTION_REFRESH, 0, 0)
    return $a -and $b
}

Set-Alias proxy Update-Proxy
proxy -Server "120.116.22.209:3128" -Override "59.127.219.48" -Enable 1

 

上面的程式碼存成 proxy_enable.ps1
 

proxy_enable.bat
 

@echo off
powershell.exe -ExecutionPolicy Bypass -File "s:\bat\ps\proxy_enable.ps1"
REM pause

 

發表於 Windows系統 | 發表迴響

[PowerShell][Proxy]用PowerShell設定Proxy – 模擬鍵盤

參考網址:
福別問的部落格 一鍵開啟proxy代理伺服器、顯示隱藏檔案副檔名、新增刪除輸入法

網路上大部分的教學是修改登錄檔, 但是實際上是行不通的, 修改登錄檔只能"表面上"把開啟代理伺服器的選項打勾, 並沒有真正地開啟代理伺服器。 這就是為什麼你可能按照網路上的方法寫了一個修改登錄檔的批次檔, 執行之後仍然不能夠從校外連線, 但是進到設定代理伺服器的頁面時, 卻又可以看到其代理伺服器已經被打勾啟動, 這時候又突然可以校外連線了。 (當你"檢視"啟動代理伺服器到底有沒有打勾時, 這時候windows後台又會做一些動作, 來"真正地"啟動代理伺服器。)

本腳本的原理就只是很簡單地模擬鍵盤的動作。
 

# 註解
# 開啟[網際網路 - 內容]
control inetcpl.cpl

# 如果是要開啟[資料夾選項],顯示隱藏檔案的副檔名,可以用RunDll32.exe shell32.dll,Options_RunDLL 7
# 如果是要開啟[地區及語言],新增或刪除輸入法,可以用control intl.cpl
# 更多進入控制台下的項目的指令,參考https://support.microsoft.com/en-us/help/192806/how-to-run-control-panel-tools-by-typing-a-command

# 讓系統取得title叫做[開啟網際網路 - 內容]的視窗
# 並讓該視窗變成當前視窗
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate('開啟網際網路 - 內容')

#停頓1秒,避免delay造成下一步無法順利進行
Sleep 1

# 按下鍵盤上的各鍵
# ' '表示按下space鍵, +表示搭配Shift, %表示搭配Alt
# 各鍵的對應表參考https://msdn.microsoft.com/en-us/library/office/aa202943(v=office.10).aspx
# 注意,每個電腦的按鍵組合可能不相同,
# 請自行做相應的修改

$wshell.SendKeys('+{TAB}')

For ($i=1; $i -le 4; $i++)
{$wshell.SendKeys('{RIGHT}')}

$wshell.SendKeys('%l')

$wshell.SendKeys('{TAB}')
$wshell.SendKeys('{TAB}')

$wshell.SendKeys(' ')

$wshell.SendKeys('{ENTER}')
$wshell.SendKeys('{ENTER}')

 

發表於 Windows系統 | 發表迴響