- 作者帖子
一舟游客bookget在win7下使用,闪退,需要在“我的电脑”--“属性”--“高级系统设置”--“高级”--“环境变量”中新建系统变量。谁知道怎么增加系统变量?
不会百度游客function Set-Env{
<#
.SYNOPSIS
设置系统变量.DESCRIPTION
设置系统变量.PARAMETER exePath
应为文件夹路径而不是具体的文件.PARAMETER level
"Machine", "User".EXAMPLE
setEnv D:\tyhg.EXAMPLE
setEnv D:\tyhg Machine.INPUTS
String.OUTPUTS
Null#>
[cmdletbinding(SupportsShouldProcess, DefaultParameterSetName = 'one')]
Param (
[parameter()]
[ValidateSet("+", "-", IgnoreCase = $true, ErrorMessage = "添加还是删除")]
[string]$Type='+',
[parameter(Mandatory,Position=0,HelpMessage="必须输入路径",ParameterSetName = 'one')]
# 验证该参数的参数值是否是文件夹
[ValidateScript({Test-Path $_ -PathType Container},ErrorMessage = "参数应为文件夹路径而不是具体的文件")]
# tab 提示 15 分钟内生成的新文件夹,适合刚装完软件
[ArgumentCompleter( {
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
$checkDir = ${Env:ProgramFiles(x86)},$Env:ProgramFiles,"D:\"
$checkDir.ForEach({ if(Test-Path $_){ Get-ChildItem $_ -Directory} }) | ForEach-Object {
if((( Get-ItemProperty $_).CreationTime | New-TimeSpan).TotalMinutes -le 15){
$rgy=(Get-ChildItem $_ -r -Directory).FullName -match ".+\\bin"
if($rgy){
$rgy
}
else{
$_.FullName
}
}
}
Get-Location
})]
[string]$Path,
[parameter(Mandatory,Position=0,ParameterSetName = 'two')]
[ValidateNotNullOrEmpty()]
[string]$String,
[parameter(Mandatory,Position=1,ParameterSetName = 'two')]
[ValidateNotNullOrEmpty()]
[string]$Value
)if($Type -eq "+"){
if($Path){
$oPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("Path", $Path + ";$oPath", "User")
}
if($String){
[System.Environment]::SetEnvironmentVariable($String, $Value, "User")
}
}else{
if($Path){
$Path = [regex]::escape($Path)
$oPath = (Get-ItemPropertyValue -Path 'HKCU:\Environment' -Name 'Path' -ErrorAction Stop) -replace "(?(^$Path;)$Path;|;$Path)",''
[System.Environment]::SetEnvironmentVariable("Path", $oPath, "User")
}
if($String){
Remove-ItemProperty -Path "HKCU:\Environment" -Name $String -ErrorAction Inquire
}
}}
一舟游客好像是在“系统变量”的path里加内容。
- 作者帖子
正在查看 3 个帖子:1-3 (共 3 个帖子)
正在查看 3 个帖子:1-3 (共 3 个帖子)
正在查看 3 个帖子:1-3 (共 3 个帖子)