CMD命令无法通过vb.net运行。 [英] CMD command is not working through vb.net.

查看:101
本文介绍了CMD命令无法通过vb.net运行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Firends,



这是命令



takeown / F文件路径



当我在以管理员身份运行的cmd提示符中使用它时,此命令工作正常并取得所请求文件的所有权。



但是当我从vb.net使用相同的命令时,它在我的vb.net代码中不起作用。



  Dim  ss  As  ProcessStartInfo =  ProcessStartInfo()

ss.UseShellExecute = True
ss.WorkingDirectory = C:\ Windows \ System32
ss.Verb = runas
Process.Start( C: \ Windows \ system32 \ cmd.exe / k takeown / F & filepath.Text&





cmd显示命令已成功处理且所有权已被取出。但是当我检查所请求文件的属性时,它显示它具有前一个所有者,并且没有对新所有者进行新的更改。

解决方案

在下面尝试

  Dim  ss  As  ProcessStartInfo =  ProcessStartInfo()
ss.UseShellExecute = True
ss.Arguments = / k takeown / F& filepath.Text&
ss.FileName = c:\windows \ system32\cmd.exe
ss.WorkingDirectory =
ss.Verb = runas
Process.Start(ss)


Hi Firends,

Here is the command

takeown /F "path of file"

when I use it in cmd prompt which is running as administrators, this command works fine and takes the ownership of requested file.

But when I use same command from vb.net, it does not work here is my vb.net code.

Dim ss As ProcessStartInfo = New ProcessStartInfo()

                   ss.UseShellExecute = True
                   ss.WorkingDirectory = "C:\Windows\System32"
                   ss.Verb = "runas"
                   Process.Start("C:\Windows\System32\cmd.exe", "/k takeown /F """ & filepath.Text & """")



cmd shows that command is processed successfully and ownership has been taken out. But when I check in the properties of requested file, it shows that it has the previous owner and no new changes to new owner.

解决方案

try below

Dim ss As ProcessStartInfo = New ProcessStartInfo()
ss.UseShellExecute = True
ss.Arguments = "/k takeown /F """ & filepath.Text & """"
ss.FileName = "c:\windows\system32\cmd.exe"
ss.WorkingDirectory = ""
ss.Verb = "runas"
Process.Start(ss)


这篇关于CMD命令无法通过vb.net运行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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