2016-10-24 36 views
-2

我在寫一個非常基本的批處理腳本來運行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文件。 任何人都可以解釋如何讓它輸出到用戶輸入的目錄以及如何映射驅動器號到該位置?

+1

您似乎很困惑'%1'的用途。它是在您調用它時傳遞給批處理文件的參數。 – DavidPostill

+0

爲什麼你有一個php標籤? – DavidPostill

+0

......應該輸出什麼樣的信息到investigation.txt – Compo

回答

0

例如:

@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命令。

+0

感謝您的答覆。輸出文件仍然會轉到本地目錄,而不是我輸入的目錄。 Net use is not mapping the Ip to a drive,it gives a error 67. – Saemund

+0

是您嘗試連接到的主機,您輸入的IP地址是否正確?它有活躍的份額嗎? 67通常意味着主機不存在,或者找不到它。 – nephi12