【问题标题】:How to set output directory and map drive letter如何设置输出目录和映射盘符
【发布时间】:2016-10-24 19:06:15
【问题描述】:

我正在编写一个非常基本的批处理脚本来运行 MD5 哈希。我需要它向用户询问输出目录,然后询问 IP 地址输出,然后将驱动器号映射到此输出。我可以让它问,但它不会将文件输出到所选目录。它将它放在运行脚本的本地目录中。它也不会将驱动器号映射到它。

@ECHO OFF
pause

REM This section prompts user for output location 

:start
CLS
set /p direct="Enter the directory output location: "

dir %1 %direct% > investigation.txt 
pause

REM This section prompts user for IP output location

set /p direct="Enter the IP output location: "

dir %1 > investigation.txt 
pause

REM Map share 

@echo Map Share

@echo off 
net use z: 
\\%1
pause

编辑

MD5 哈希值将写入 txt 文件。 谁能解释如何将其输出到用户输入的目录以及如何将驱动器号映射到该位置?

【问题讨论】:

标签: php batch-file scripting


【解决方案1】:

例如:

@echo off
set /p dir="enter directory: "
set /p ip="enter ip: "
net use Z: \\%ip%\%dir%
echo "asdf testing testing 1 2 3 ..." > Z:\output.txt

此代码使用描述性但适当短的变量名称,以及net use 命令的适当语法。

【讨论】:

  • 感谢您的回复。输出文件仍然进入本地目录,而不是我输入的目录。 Net use 没有将 Ip 映射到驱动器,它给出了错误 67。
  • 是您尝试实时连接的主机,您输入的 IP 正确吗?它有活跃的份额吗? 67 通常意味着主机不存在,或者找不到它。
猜你喜欢
  • 1970-01-01
  • 2016-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-21
  • 2014-10-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多