Computing.Net > Forums > Programming > Batch adding adding var to output

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

Batch adding adding var to output

Reply to Message Icon

Name: action_owl
Date: January 12, 2009 at 09:13:31 Pacific
OS: Windows Server 2003
CPU/Ram: pentium 3 - 1gb ram
Manufacturer/Model: ? / ?
Subcategory: Batch
Comment:

Hello all,

I have a simple logoff batch script that looks like this:

echo Last Logoff for %Username% was on: %date% at %time% > \\Server\Apps\Logs\Logoff\%Username%.txt

I need to add the date and the words "logoff" onto the filename so it does not overwrite the last file.

the output would look something like:
logoff_username_date.txt

I tried using using:
logoff_%Username%_%date%.txt

it almost works, but the file looks like:

"logoff_user001_Mon"

and the file doesnt have .txt

any help is greatly appreciated
thanks


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: action_owl
Date: January 12, 2009 at 09:29:42 Pacific
Reply:

figured it out

(now I just need to get it to work so that if they logon/off multiple times there is an entry for it

@echo off

echo %DATE%
set myDATE=%DATE:~7,2%%DATE:~4,2%
echo myDATE is %myDATE%
echo A Logoff entry for %Username% was created on: %myDATE% at %time% > %Username%_logoff_%myDATE%.txt


Report Offensive Follow Up For Removal
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch adding adding var to output

batch: copy one var to another www.computing.net/answers/programming/batch-copy-one-var-to-another/9107.html

Batch file adding text to file also www.computing.net/answers/programming/batch-file-adding-text-to-file-also/16756.html

Adding Var to Batch file www.computing.net/answers/programming/adding-var-to-batch-file/17129.html