Help - Search - Members - Calendar
Full Version: windows batch
Hydrogenaudio Forums > Misc. > Off-Topic
smok3
how do i assign a value to the variable from a text file, like

SET var=more c:\stuff.txt
or
SET var=type c:\stuff.txt

isnt working?
Andavari
This doesn't answer your question however this is the SET help/usage file.
QUOTE
set /?

Displays, sets, or removes cmd.exe environment variables.

SET [variable=[string]]

  variable  Specifies the environment-variable name.
  string    Specifies a series of characters to assign to the variable.

Type SET without parameters to display the current environment variables.

If Command Extensions are enabled SET changes as follows:

SET command invoked with just a variable name, no equal sign or value
will display the value of all variables whose prefix matches the name
given to the SET command.  For example:

    SET P

would display all variables that begin with the letter 'P'

SET command will set the ERRORLEVEL to 1 if the variable name is not
found in the current environment.

SET command will not allow an equal sign to be part of the name of

You may need to change var to: variable
Synthetic Soul
Thank woody_woodward for this one:

CODE
SET /P var=<"c:\stuff.txt"


Edit:

"SET /P" sets a variable from the prompt, while "<" redirects the contents of a file to a command.

This one eluded me for ages, until woody came to the rescue.

Obviously you don't need the quotes around the file path - but I thought I'd put them there so that you can change the path without worring.
smok3
tnx Synthetic Soul and tnx woody, this is working as expected.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.