Tech Support Guy banner
Status
Not open for further replies.
1 - 5 of 5 Posts

·
Retired Moderator
Joined
·
106,726 Posts
dir >c:\hostname.txt

The above command saves the directory listing the that name in the root of C: Most other commands will accept the same redirection character.

Redirection is dependent on exactly what command you're running, can you be more specific?
 

·
Registered
Joined
·
174 Posts
Discussion Starter · #3 ·
I want to have the file name be a variable. Such as dir > C:\hostname.txt I need to have a machine unique filename. I have a script that saves a log file, I need to run this script locally on 30 machines on a regular basis. Right now I think it will be easier to have a single script that saves the log to a single location. The unique file name will help me sort which machine each log came from.
 

·
Retired Moderator
Joined
·
106,726 Posts
What I would do if the bare name is in the file in question is the following.

Create a file named SET.TXT with the text "SET=MYVAR " (without the quotes) and save it.

COPY SET.TXT+C:\HOSTNAME.TXT SETCMD.BAT
CALL SETCMD

This will set the environment variable MYVAR to the file name in question.
 
1 - 5 of 5 Posts
Status
Not open for further replies.
Top