正文

简介

由于win10 ltsc2019 不带有windows store 应用商店,所以导致有些应用比如"照片"的获取很不方便,但是自己手动输入命令又过于麻烦,所以就想着写个脚本来实现。

脚本构成

appStore 目录

path.bat

@ECHO OFF
setlocal EnableDelayedExpansion
color 02
title 安装微软商店脚本 - for 小渔
PUSHD %~DP0 & cd /d "%~dp0"
%1 %2
mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :runas","","runas",1)(window.close)&goto :eof
:runas
powershell Set-ExecutionPolicy RemoteSigned
::启用执行.ps1
exit

install.ps1

param([switch]$Elevated)

function Test-Admin {
  $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
  $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

if ((Test-Admin) -eq $false)  {
    if ($elevated) 
    {
        # tried to elevate, did not work, aborting
    } 
    else {
        Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))

        ## 核心 ##
        cd D:\appstore\ #进入目录#
        get-appxpackage *store* | remove-Appxpackage #清除残留#
        Add-AppxPackage * #安装程序#
        start shell:AppsFolder\Microsoft.WindowsStore_8wekyb3d8bbwe!App #启动程序#
}

exit
}

'请等待30S左右,应用商店正在部署中,部署完毕会自动打开。'

robocopy appStore d:/appstore /e
path.bat && Timeout 5 && PowerShell.exe -file install.ps1

脚本下载


使用说明

使用说明:

鼠标右键 >>>>运行 安装.bat 即可

Last modification:May 31st, 2021 at 11:39 pm
如果觉得我的文章对你有用,请随意赞赏