1

The question on the homework sheet is:

Update the folder search path for batch script file execution to include the "Processing" subfolder, and then display the folder search path. (Make sure you preserve the folder search path)

I'm not sure what is being asked exactly, or what the expected outcome is meant to be.

If a user was to execute the command for the question what would they be expecting it to do?

3 Answers 3

0

I think the question is 2 parts:

1 - Make a note of the processing sub folder full path (E.G c:\folder\folder2\processing)
2 - Display the path on screen.

You need something like the following pseudo code

set variable name = folder location
echo variable name on screen

3
  • But why would someone use this command? If you could explain that (if you don't mind) I should be able to understand the question a little better (hopefully).
    – Jane
    Sep 17, 2012 at 10:58
  • Typically like this, not often but think about if you needed multiple files/folders within a folder. You'd get them via a loop - each iteration of the loop stores the current folder as a variable. Here is a good example
    – Dave
    Sep 17, 2012 at 10:59
  • Argh god. I think I need to break this down. What exactly is updating a folder search patch? What is the outcome and why is it used?
    – Jane
    Sep 17, 2012 at 11:16
0

The search path is where the operating system will automatically look for executable files/scripts, so that you can run them using just their name (foo.sh, foo.cmd) instead of the absolute or relative path (/usr/bin/foo.sh, C:\Windows\System32\foo.cmd). The question asks you to add a particular folder to the system- or user-defined PATH and then display the changed PATH.

3
  • So the user would use this command to run a batch file by name eg in cmd prompt > run Main.bat - instead of having to search for it through it's path?
    – Jane
    Sep 17, 2012 at 11:40
  • C:\> main.bat instead of C:\> C:\Users\Jane\Documents\main.bat, yes. Sep 17, 2012 at 11:44
  • Yay! Thanks that makes so much more sense. :)
    – Jane
    Sep 17, 2012 at 11:46
0

SET without parameters will display the current environment variables (including PATH).

SET variable= without a value will delete variable from the environment.

SET variable=value will assign value to variable. You can now use %variable% in batch files whenever you need its value (for example echo %variable% to print its value).

Also note that SET variable=new_value will overwrite the existing value, if any. Since you're being asked to preserve the existing value, you'll need to use SET variable=%variable%;new_value (semicolons of course being the delimiters in case of PATH). This will of course append new_value to the existing value, then assign the entire string to variable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .