Pergunta

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.

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()

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

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

What is mklink?

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.

How do I do this correctly?

Foi útil?

Solução

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()
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top