【发布时间】:2014-07-18 04:25:13
【问题描述】:
我正在从 bat 文件运行 Powershell 脚本。这两个文件放在网络服务器上,我试图通过访问网络服务器文件夹从我的机器上运行这些文件。我收到以下错误:
CMD 不支持将 UNC 路径作为当前目录。
当我执行 bat 文件时,它会尝试从路径中读取脚本文件
C:\Windows\System32
不是来自 bat 文件中设置的当前目录。
当我在本地机器上运行时,这个脚本和 bat 文件可以正常工作。
我尝试在 Google 上找到这个,可能的解决方案需要更改网络服务器上的一些设置,这在我的情况下是不可能的。
对此有什么可能的解决方案?
我正在使用 PowerShell 2.0
这是我运行 Powershell 脚本的 bat 文件
setlocal & pushd .
:getting current directory
cd /d %~dp0
Powershell.exe Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Powershell.exe . '%CD%\Hotfix-Automation-Installer.ps1' crpt
exit /B
【问题讨论】:
标签: batch-file cmd powershell-2.0