我想创建一个存储于系统范围内的环境变量。
我在 Powershell 中使用过的内容:
$Env:MyVar = 'Some value'
我gci Env:
可以确认,该变量已成功创建。但是,Windows(Win11)的“高级系统设置”中仍然缺少该变量。
我该如何设置才能让它在菜单中可见?
我想创建一个存储于系统范围内的环境变量。
我在 Powershell 中使用过的内容:
$Env:MyVar = 'Some value'
我gci Env:
可以确认,该变量已成功创建。但是,Windows(Win11)的“高级系统设置”中仍然缺少该变量。
我该如何设置才能让它在菜单中可见?
我有这个配置脚本,它将文件从服务器复制到客户端。此示例包含一个 Access Runtime 应用程序,需要在客户端本地安装。
如果目标文件夹不存在,则会先创建该文件夹,然后将该文件粘贴到该文件夹中。
# Install myFolder
$install_Folder = {
echo 'Creating folder...'
New-Item -Path "C:\Program Files\" -Name "myProgram" -type directory
icacls 'C:\Program Files\pzCAFM' /grant:r 'User:(OI)(CI)F'
echo 'Done.'
}
# Install myFile
$install_File = {
echo 'Copying the file to destination...'
Copy-Item "\\myserver\myshare\Database.accdr" -Destination "C:\Program Files\myprogram\"
echo 'Done.'
}
# Check if the folder exists and go to install otherwise start deployment
if (Test-Path -Path 'C:\Program Files\myProgram')
{
echo 'Folder exists. Stopping any open process...'
if (Get-Process -Name 'MSACCESS'){
Stop-Process -Name 'MSACCESS'
Start-Sleep -Seconds 2
Remove-Item -Path 'C:\Program Files\myProgram\Database.laccdr' -Force
Start-Sleep -Seconds 2
}
echo 'Folder exists. Proceed with updating the file'
.$install_File
}
else {
echo 'Folder not found. Proceed with initial deployment.'
.$install_myFolder
Start-Sleep -Seconds 5
.$install_File
echo 'Installation complete'
}