1

我们想让我们的应用程序自动升级。由于 Windows IOT 没有 Windows Store,我们必须手动进行。

这是我们的解决方案。如果我们的网络服务器上有新版本,我们的应用程序每 7 天检查一次。如果是,应用程序将其下载到文件夹 \LocalState\Install 中。

下一部分是 powershell 脚本,它每小时检查该文件夹中是否有文件。如果是她安装它。

问题是我们无法将脚本作为计划任务启动,也无法使用 powershell -File 运行它(我们尝试了 UnRestricted、Bypass 和 RemoteSigned 的所有选项,我们还对其进行了签名)。

脚本没问题,当我们从命令行启动它时它就可以工作。

有什么解决办法吗?请帮忙 :)

    $items = Get-ChildItem -Path "c:\Data\Users\DefaultAccount\AppData\Local\Packages\"

foreach ($item in $items)
{
      # if the item is a directory, then process it.
      if ($item.Attributes -eq "Directory")
      {
            if ($item.name -Match "<app name>") {           
                "Backuping ini files..."
                $AppPath = "c:\Data\Users\DefaultAccount\AppData\Local\Packages\" + $item + "\LocalState"
                $AppName = $item
                cp "$AppPath\*.ini" "C:\Data\Users\Administrator\Temp"

                $path1 = "c:\Data\Users\DefaultAccount\AppData\Local\Packages\" + $item.name + "\LocalState\Install\"
                $path = Get-ChildItem -Path $path1          
                $dependencies1 = $path1 + "Dependencies\ARM\"
                $dependencies = Get-ChildItem -Path $dependencies1              
                "Dependencies..."
                foreach ($dependency in $dependencies)
                {
                      if ($dependency.Attributes -ne "Directory")
                      {
                            "***** Installing: " + $dependency
                            Add-AppxPackage -ForceApplicationShutdown $dependencies1$dependency                   }
                }

                "APP update..."
                foreach ($p in $path)
                {
                      # if the item is NOT a directory, then process it.
                      if ($p.Attributes -ne "Directory")
                      {
                        if ($p.name -Match "appxbundle") {
                            "***** Installing: " + $p
                            Add-AppxPackage -ForceApplicationShutdown $path1$p                  
                        }   
                      }
                }       

                "Removing install files..."
                rm $path1\* -Recurse

                "Restoring ini files..."
                cp "C:\Data\Users\Administrator\Temp\*.ini" "$AppPath\"

                "Setting APP as default app"
                IotStartup add headed $AppName
                "Done"
            }
      }
}
4

0 回答 0