|
发表于 2020-10-19 15:19:56
|
显示全部楼层
嗯呐,我只不过试图解释一下“找不到路径”所产生的原因,如何做到64位和32位同时兼容我没有去关注。或许你的场景很特别,就一条命令,把它转成exe来运行有什么特殊用途吗?
如果要我来做的话我会直接在cmd中输入,不用脚本。
如果是复杂点的问题我宁愿直接用脚本实现,而不是脚本转exe,更复杂的问题我会考虑直接写exe实现。
那一条 PowerShell 命令好像只能设置存档属性,其它属性改不了吧?
下面的 PowerShell 可以设置或删除 系统、只读、隐藏、存档 属性。
- $s = [IO.FileAttributes]::System;
- $r = [IO.FileAttributes]::ReadOnly;
- $h = [IO.FileAttributes]::Hidden;
- $a = [IO.FileAttributes]::Archive;
- $file = Get-Item "$ENV:winDir\System32\drivers\etc\hosts" -Force;
- #以下设置属性 相当于 attrib +s +r +h fileSpec
- If ( !($file.Attributes -BAND $s) ) {
- $file.Attributes = $file.Attributes -BOR $s;
- }
- If ( !($file.Attributes -BAND $r) ) {
- $file.Attributes = $file.Attributes -BOR $r;
- }
- If ( !($file.Attributes -BAND $h) ) {
- $file.Attributes = $file.Attributes -BOR $h;
- }
- #以下删除属性 相当于 attrib -s -r -h fileSpec
- <#
- If ($file.Attributes -BAND $s) {
- $file.Attributes = $file.Attributes -BXOR $s;
- }
- If ($file.Attributes -BAND $r) {
- $file.Attributes = $file.Attributes -BXOR $r;
- }
- If ($file.Attributes -BAND $h) {
- $file.Attributes = $file.Attributes -BXOR $h;
- }
- #>
- $file.Attributes;
- cmd /c pause
复制代码
|
|