【问题标题】:create a folder in C:\program files and copy a dll file into在C:\\program files新建一个文件夹,复制一个dll文件到
【发布时间】:2023-02-10 00:05:33
【问题描述】:

我想在 C:\program files 中创建一个目录,并将一个 dll 文件复制到

我可以使用以下 PS 创建目录

New-Item -ItemType Directory -Force -Path "C:\Program Files\admintool\zep"

我的 dll 文件名为 zep.dll

如何将 zep.dll 复制到 C:\Program Files\admintool\zep 并使用 regsvr32.exe zep.dll 注册它

PS应该创建目录并复制我的dll文件并一步注册它。

那可能吗??

问候

【问题讨论】:

  • “PS 应该一步创建目录并复制我的 dll 文件”——为什么这很重要?

标签: powershell


【解决方案1】:

使用Test-Path判断目录是否已经存在,然后使用Copy-Item复制文件:

$filePath = 'C:path	ozep.dll'
$directoryPath = "C:Program Filesdmintoolzep"

# test if folder already exists
if(-not(Test-Path -Path $directoryPath -PathType Container)){
    # folder doesn't already exist, let's create it!
    New-Item -Path $directoryPath -ItemType Directory
}

# now copy the file
Copy-Item -Path $filePath -Destination $directoryPath

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 2012-08-17
    • 1970-01-01
    • 2023-03-23
    • 2023-01-14
    • 1970-01-01
    • 2014-06-01
    相关资源
    最近更新 更多