Jon B
Jon B

Reputation: 11

Batch Script Returns Error For Valid Commands

The following script works as expected:

echo off

REM This script is designed to demonstrate capture of volatile data from a Post Windows XP client 

date /T > c:/Users/Jon/Desktop/file.txt
time /T >> c:/Users/Jon/Desktop/file.txt
getmac >> c:/Users/Jon/Desktop/file.txt
hostname >> c:/Users/Jon/Desktop/file.txt
ipconfig /all >> c:/Users/Jon/Desktop/file.txt
arp -a >> c:/Users/Jon/Desktop/file.txt
ipconfig /displaydns >> c:/Users/Jon/Desktop/file.txt
netstat -an >> c:/Users/Jon/Desktop/file.txt

However, when a user input for the location of the output file is added :

echo off

REM This script is designed to demonstrate capture of volatile data from a Post Windows XP client 

set /p path="Enter Drive Letter "
date /T > %path%:file.txt
time /T >> %path%:file.txt
getmac >> %path%:file.txt
hostname >> %path%:file.txt
ipconfig /all >> %path%:file.txt
arp -a >> %path%:file.txt
ipconfig /displaydns >> %path%:file.txt
netstat -an >> %path%:file.txt

an error is returned that the commands are not valid commands except for Date and Time which are exported as expected into %path%:file.txt

Please may I have some advice to resolve this issue?

Many Thanks

Jon

Upvotes: 1

Views: 42

Answers (1)

MC ND
MC ND

Reputation: 70923

path variable is used to enumerate the folders where executable files will be searched for. If you overwrite it, only internal commands will be available (unless you include the full path in the call)

To solve the problem just use a different variable name.

Upvotes: 2

Related Questions