- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有以下 powershell 2.0 脚本:
function getFreeDrive
{
[char[]]$driveLetters = @([char]'E'..[char]'Z')
foreach ($d in $driveLetters) {
if(!(Test-Path -Path "$d`:" -IsValid)) {
return $d
}
}
}
$drive = getFreeDrive
subst "$drive`:" T:\temp
ls "$drive`:\" # just a dummy command
subst "$drive`:" /D
我想要脚本
脚本在我第一次运行时运行良好。如果我在同一个 shell 中第二次运行该脚本,我会从 ls 命令中收到一条错误消息,提示找不到驱动器。如果我打开一个新的 shell 并运行脚本,它会再次正常运行。
我的脚本有什么问题,如何让它在同一个 powershell 实例中运行多次?
或者也许有替代 subst 命令的方法?我尝试使用 powershell 驱动器,但它不适用于其他 Windows 程序(例如 devenv.exe)。
最佳答案
另一种方法是使用 PSProviders 和更准确的 PSDrives(查看 get-help about_providers):
PS > New-PSDrive -Name "tr" -PSProvider filesystem -Root "c:\temp"
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
tr 28,15 FileSystem C:\temp
PS > ls tr:*.c
Répertoire : C:\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 01/08/2012 05:28 994 test.c
PS > Remove-PSDrive -Name "tr"
问题是这些驱动器不能与 shell explorer.exe 一起使用。
关于windows - powershell 脚本和 subst 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15093347/
假设我与两个内图f和g有传递关系~。假设 f 和 g 处处一致且 f a ~ f b ~ f c那么有两种方式显示g a ~ g c:通过给定的等式将每个 f 转换为 g 然后应用及物性,或者应用传递
我有一个 Makefile,大致如下所示: FIGURES = A1_B1_C1.eps A2_B2_C2.eps A3_B3_C3.eps NUMBERS = 1 2 3 all : $(FIGUR
假设我与两个内图f和g有传递关系~。假设 f 和 g 处处一致且 f a ~ f b ~ f c那么有两种方式显示g a ~ g c:通过给定的等式将每个 f 转换为 g 然后应用及物性,或者应用传递
我刚刚编写了一个程序,在循环内调用 subst 以及许多其他函数,到目前为止,subst 函数调用占用的时间最多时间。下面是一段概念性的代码片段,其中包含了我编写的程序的精髓。 (loop
当我们附加可移动驱动器时,操作系统会为其分配驱动器号。另一种方法是使用 subst 命令将本地文件夹映射到任何驱动器。我正在编写资源管理器的 Hook ,我需要在其中区分这两个驱动器。我尝试使用 Ge
在Windows中使用subst命令创建虚拟驱动器有什么意义。我正在为我的原始源代码目录创建虚拟驱动器,然后使用虚拟驱动器进行编译、编辑等所有操作。 它的主要用途是什么?我们不能在我 checkout
我想在 for 中进行字符串替换使用命名捕获阻止。我希望得到数字 1,2,3 作为输出。但它是Nil第一次运行,然后 1 和 2 用于第二次和第三次运行。如何使用 .subst在循环构造中正确吗?我在
我正在公司开发一个内部搜索引擎,使用 Flask 和 sqlalchemy(sqlite) 用 python 编写。我目前的问题是我愿意。 A.) 查询描述字段的一定信息量B.) 最好在它之前 50
我已经通过 HKCR\Drive\shell\MapLocalDriveHere\command 中的注册表向我的上下文菜单添加了一个命令,这样当我右键单击一个驱动器时。我希望它给我右键单击的驱动器名
我有以下 powershell 2.0 脚本: function getFreeDrive { [char[]]$driveLetters = @([char]'E'..[char]'Z')
我在从 Windows 批处理文件调用 SUBST 时遇到问题。我想使用一批来创建虚拟驱动器映射,并使用第二批来卸载驱动器。但是卸载给出了错误信息: The system cannot find th
情况 我们有一个 git 工作流程,其中所有发布版本都堆叠在 master 分支上,当提交准备好部署时,我们为其添加一个标签,然后使用 git archive 构建要部署的包。 我们使用一个 vers
我参加了 CPP 语言类(class),我试图了解 makefile 中“subst”的用法(一般情况下)以及此 makefile 中的具体用法。 我试图用谷歌搜索“subst”的用法,但没有找到。
我需要将子字符串移动到时间戳字段中。但是如果我编译它,我会得到错误号 RNF7416 - EVAL 运算中表达式左右两侧的操作数类型不匹配。 代码: MONITOR; TSTPFIELD = %S
我想知道是否有一种通用的方法可以使用驱动器号(例如 X:\foo\bar.txt )将路径解析为其等效的 UNC 路径,这可能是以下之一: X:\foo\bar.txt如果 X:是真正的驱动器(即硬盘
我有以下列表: (1 (2)) 我想用 (2 (3)) 代替 (2) 以获得: (1 (2 (3))) subst 的使用没有返回想要的结果: (subst '(2 (3)) '(2) '(1 (2)
我在 Windows 上的开发环境包括子文件夹,即文件夹 c:\MyBuild 可以替换为驱动器号,例如 t: 在 Ubuntu 子系统终端中,我可以将文件夹绑定(bind)到挂载,如下所示 sudo
我在 Windows 的 subst 文件夹中运行 python 脚本: c:\MyFolder\Tmp\Code\subst O: . O:\script.py script.py 正在运行 get
我正在尝试在我的 Windows 设置上映射一个虚拟驱动器,我使用的工具之一不喜欢文件名中的空格。 在命令行上,我会执行以下操作 subst l: "c:\Program Files\Complier
使用 创建的文件夹SUBST cmd 不工作 IIS 6 .在 IIS 7 (使用 Windows 7)浏览时未列出虚拟驱动器,以便为虚拟目录设置物理路径。 任何人都可以告诉我如何解决这个问题? 除了
我是一名优秀的程序员,十分优秀!