如何运行Windows命令"mklink";从vb.net应用程序? [英] How to run windows command "mklink" from vb.net application?

查看:93
本文介绍了如何运行Windows命令"mklink";从vb.net应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从我的vb.net项目中运行"mklink path1 path2".我没做到我已经尝试过使用Shell()函数和Process.

I want to be able to run "mklink path1 path2" from my vb.net project. I fail to do that. I have tried with Shell() function and with Process.

仅打开cmd.exe窗口而不执行任何操作:

With this it only open cmd.exe window and does nothing:

        Dim process As New Process
        process.StartInfo.FileName = "cmd.exe"
        process.StartInfo.Arguments = "mklink """ + arma2oaAddons + """ """ + arma2Addons + """ /j"
        process.StartInfo.WorkingDirectory = "C:\"
        process.Start()

与此有关,我得到错误找不到文件".它找不到mklink.:

And with this I get error "File not found". It can't find mklink.:

        Shell("mklink """ + arma2oaAddons + """ """ + arma2Addons + """ /j")

什么是mklink?

Mklink 是MS Windows命令行实用程序,可用于在MS Windows中创建符号链接或符号链接和硬链接.它是CMD shell的一部分,例如dir命令.

Mklink is a MS Windows command line utility that you can use to create symbolic links or symlinks and hard links in MS Windows. It’s a part of CMD shell such as dir command.

如何正确执行此操作?

推荐答案

第一个示例(如果可以的话),但是如果要执行它,则需要使用cmd.exe /c

the first example if fine except you need to use cmd.exe /c if you want it to be executed so

Dim process As New Process
process.StartInfo.FileName = "cmd.exe"
process.StartInfo.Arguments = "/c mklink """ + arma2oaAddons + """ """ + arma2Addons + """ /j"
process.StartInfo.WorkingDirectory = "C:\"
process.Start()

这篇关于如何运行Windows命令"mklink";从vb.net应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆