xp_cmdshell 将文件目录写入文本文件
如何将文件目录写入文本文件?我想使用的目录是 C:\
我现在拥有的代码是
exec xp_cmdshell 'dir *.exe & echo > file_directory.txt';--
但它并没有写入文件。这还需要我说吗...
exec xp_cmdshell 'cd c: \ & dir *.exe & echo > file_directory.txt';--
how do I write my file directory to a text file? The directory I want to use is C:\
The code I have now is
exec xp_cmdshell 'dir *.exe & echo > file_directory.txt';--
It's not writing to a file though. Do I need to say this...
exec xp_cmdshell 'cd c: \ & dir *.exe & echo > file_directory.txt';--
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cd
(单独)仅设置工作目录,不会更改工作磁盘驱动器。如果您(可能)需要更改工作驱动器和工作目录,则需要pushd c:\
或cd /dc:\
。更简单的解决方案是完全限定文件名:
但写入 C: 的根目录通常不是一个好主意。微软试图让这一点变得更加困难,因为向系统分区的根目录开放写入权限会带来各种安全风险。
(更新:)
我想你想要的是
cd
(by itself) only sets the working directory, it won't change the working disk drive. If you (may) need to change the working drive and working directory you needpushd c:\
orcd /d c:\
.The easier solution is to fully-qualify the file name instead:
But it's generally not a good idea to write to the root of C:. Microsoft has tried to make this harder, for the very good reason that opening up write privilege to the root of your system partition opens up all sorts of security risks.
(Update:)
I think what you want is