Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What I'm trying to accomplish, is to have the batch file prompt the user to input their specific folder on our team's directory, and then prompt for a specific command to be used, and redirected to a TXT file on that directory. To keep it simple, the name of the file is the complete command. Batch file:

@echo off
set /p FOL=enter your folder name on "N:\GROUP NETWORK FOLDER\":
set /p CMD=enter command:
%FOL%
%CMD% > "\\NETWORK DRIVE\GROUP NETWORK FOLDER\%FOL%\%CMD%.TXT"

Running the batch file results in this output:

enter your folder name on "N:\GROUP NETWORK FOLDER\": MY FOLDER
enter command:ping Remote-PC
MY FOLDER is not a recognized as an internal or external command, operable program or batch file.

Ultimately, the batch file works just as it should, but I cannot figure out how to get rid of the error: MY FOLDER is not a recognized as an internal or... etc.

I feel like this is an extremely simple script, and a psuedo success, as it accomplishes what I want to accomplish, but I just can't figure out how to get rid of the error.

share|improve this question
1  
a combination of Paul's suggestion, with a redirect to null, solved my problem. Paul's suggestion got rid of the error, but spit out 'MY FOLDER' after command was completed successfully. the below edit to my batch, corrects both problems. Thanks Paul. @echo off set /p FOL=enter your folder name on "N:\GROUP NETWORK FOLDER\": set /p CMD=enter command: echo %FOL% > nul %CMD% > "\\NETWORK DRIVE\GROUP NETWORK FOLDER\%FOL%\%CMD%.TXT" –  btgream Dec 15 '13 at 22:55
add comment

1 Answer

The third line of your batch file is this:

%FOL%

So this will attempt to run %FOL% as a command - which it isn't, so it errors.

If you just want to say the folder name back to the user say

echo %FOL%
share|improve this answer
    
Paul, Thank you. This is significantly better, would you know of a way to accomplish this without it actually echoing your input? Just for the sake of keeping things neat and tidy. This is perfect for now. Thanks again. –  btgream Dec 15 '13 at 22:36
    
disregard that. I simply redirected the echo to nul. for those wondering: –  btgream Dec 15 '13 at 22:52
1  
@user2970673 Why is that line there at all? If you redirect the echo to nul you can just delete it. Paul was under the assumption you wanted it to display in your batch file. If you don't, just delete the whole life. –  Rik Dec 15 '13 at 22:57
1  
@Rik indeed it shouldn't be there.. but to hazard a guess as to why it is there, maybe originally he had in mind CD %FOL% then running the command > blah.txt without needing to specify the path in the line that runs the command. –  barlop Dec 15 '13 at 23:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.