There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
(unresolved) date prob


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
techi's Avatar
Junior Member with 15 posts.
 
Join Date: Dec 2003
10-Dec-2003, 06:48 PM #1
Question (unresolved) date prob
ok first off, hi

i know there are things on your forum about this but all of them leave me in the dark, im a complete beginner, iv never done dos b4 so i dont understand a thing really.

im running win2k server
i have xp and 2000 machines logging in
they run the following batch file at login:

Quote:
echo %username% %computername% %date% time%>>\\Srv2K\LoginLog$\Users.txt
writes to Users.txt on shared area:-

Quote:
Administrator SRV2K Mon 08/12/2003 22:11:53.72
Administrator SRV2K Mon 08/12/2003 22:21:20.71
Administrator SRV2K Mon 08/12/2003 22:24:53.43
trial TECHI-BUILD Mon 12/08/2003 22:46:27.13
Administrator SRV2K Wed 10/12/2003 21:27:25.20
this is to store who was last logged into a machine (and is deliberately crashing them, to a hdd failure), time and date are important in the file text.

i want to be able to store the file name as day.txt (Mon.txt, Tue.txt or 0.txt, 1.txt)

i have tried lots of examples, and would prefer it if there were NO temp.bat files used.

as this is to be used in a school environment speed is also a key issue, as the large .bat files the previous technician writ are being closed on execution, then lil brats are phoning me up asking why their network drive isnt working.
techi's Avatar
Junior Member with 15 posts.
 
Join Date: Dec 2003
10-Dec-2003, 07:03 PM #2
Lightbulb semi solution
ok i got a little closer

Quote:
set filename=%date%
echo %username% %computername% %time%>>\\Srv2K\LoginLog$\%filename%.txt
pause
this does what i want but stores files as just the day with no extentions (e.g. Mon)

it still houses the correct information but i need somthing to the effect of:-

%date% + %.txt%

as you can see im not used to dos programming (or command prompt programming for those who dont think the two are part of one)
mbechard's Avatar
Junior Member with 16 posts.
 
Join Date: Nov 2003
11-Dec-2003, 09:11 PM #3
If there is a domain controller, there is a simpler way to do this. I have some notes that I used a couple times. This sets the domain controler as a time server that is synched with a military time server. You don't need to run it as a batch file at every login, its automatic.

Set time on server and domain computers

net time /setsntp:192.5.41.209

net time /DOMAIN:domainname/set

net stop w32time

w32tm -once

net start w32time
mbechard's Avatar
Junior Member with 16 posts.
 
Join Date: Nov 2003
11-Dec-2003, 09:13 PM #4
never mind - I read your problem..
techi's Avatar
Junior Member with 15 posts.
 
Join Date: Dec 2003
12-Dec-2003, 01:56 PM #5
ok - thx for trying though
techi's Avatar
Junior Member with 15 posts.
 
Join Date: Dec 2003
12-Dec-2003, 01:58 PM #6
actualy cant somthing be done like a file is kept with a referance number in as the date, the current date is checked to this, the filename is the differance in days between the two dates?

so in the file is kept "15/12/2003"
current date is "20/12/2003"
filename is "5.txt"

therefore a fresh log is always kept

thinking aloud: why use a file, why not hard code the check date the day the batch file is issued

Quote:
set check=Mon 15/12/2003
set today=%date%
filename=today-check
echo %username% %computername% %time%>>\\Srv2K\LoginLog$\%filename%.txt
pause
common i only need help with code the brain is working well

Last edited by techi : 12-Dec-2003 02:06 PM.
Jedi_Master's Avatar
Distinguished Member with 5,435 posts.
 
Join Date: Mar 2002
Location: Kentucky
Experience: Advanced...I guess... ;)
12-Dec-2003, 08:56 PM #7
Howdy techi...

I've tested this in XP locally, should work in W2K also...

_____________________________________________________

set filename=%date%
echo %username% %computername% %date% %time% >> c:\%filename%

@echo off
cls
if exist c:\sun goto sun
if exist c:\mon goto mon
if exist c:\tue goto tue
if exist c:\wed goto wed
if exist c:\thu goto thu
if exist c:\fri goto fri
if exist c:\sat goto sat

:sun
ren c:\sun sun.txt
copy c:\sun.txt/a+c:\sun/b
del c:\sun
goto end

:mon
ren c:\mon mon.txt
copy c:\mon.txt/a+c:\mon/b
del c:\mon
goto end

:tue
ren c:\tue tue.txt
copy c:\tue.txt/a+c:\tue/b
del c:\tue
goto end

:wed
ren c:\wed wed.txt
copy c:\wed.txt/a+c:\wed/b
del c:\wed
goto end

:thu
ren c:\thu thu.txt
copy c:\thu.txt/a+c:\thu/b
del c:\thu
goto end

:fri
ren c:\fri fri.txt
copy c:\fri.txt/a+c:\fri/b
del c:\fri
goto end

:sat
ren c:\sat sat.txt
copy c:\sat.txt/a+c:\sat/b
del c:\sat
goto end

:end

______________________________________________________

Haven't tested from a network, just change everywhere it says
c:\ to where the network share is...
__________________
Just my humble 2 pennies...

And as always, just trying to help...

Last edited by Jedi_Master : 12-Dec-2003 10:14 PM.
techi's Avatar
Junior Member with 15 posts.
 
Join Date: Dec 2003
12-Dec-2003, 09:09 PM #8
ty, i will try this later, its late now.
Jedi_Master's Avatar
Distinguished Member with 5,435 posts.
 
Join Date: Mar 2002
Location: Kentucky
Experience: Advanced...I guess... ;)
12-Dec-2003, 10:01 PM #9
Hey techi I edited my post, forgot to add the goto end statement ( the old one will still work, this way may be a tad faster )...
techi's Avatar
Junior Member with 15 posts.
 
Join Date: Dec 2003
13-Dec-2003, 06:19 AM #10
i put pause at the end for testin purposes,

The system cannot find the file specified.
The system cannot find the file specified.
Could Not Find c:\sun
Press any key to continue . . .



will i have to create the file initialy manualy to get it started?
Jedi_Master's Avatar
Distinguished Member with 5,435 posts.
 
Join Date: Mar 2002
Location: Kentucky
Experience: Advanced...I guess... ;)
13-Dec-2003, 11:45 AM #11
No you don't have to create the file, it can't find it because it isn't sunday yet...
smontejo's Avatar
Junior Member with 11 posts.
 
Join Date: Aug 2003
Location: Bogotá-Colombia
13-Dec-2003, 03:33 PM #12
I'm sorry but I dont understand the whole problem. Isn't

set file=%date%.txt

enough?
techi's Avatar
Junior Member with 15 posts.
 
Join Date: Dec 2003
13-Dec-2003, 09:03 PM #13
no that does this:-

Batch start----------

echo %username% %computername% %time%>>\\Srv2K\LoginLog$\%date%.txt

------------Batch end

log start------------

Administrator SRV2K 22:11:53.72 08/12/2003
Administrator SRV2K 22:21:20.71 08/12/2003
Administrator SRV2K 22:24:53.43 08/12/2003

-------------log end

in a file called Mon with no extention

note the date at the end of the log sentance even though its not asked to in the batch file.
Jedi_Master's Avatar
Distinguished Member with 5,435 posts.
 
Join Date: Mar 2002
Location: Kentucky
Experience: Advanced...I guess... ;)
13-Dec-2003, 09:21 PM #14
Actually that is coming from %time%
zephyr's Avatar
Distinguished Member with 2,386 posts.
 
Join Date: Nov 2003
Location: Southern California, USA
14-Dec-2003, 02:29 AM #15
I don't know if this will answer your needs since it's not exactly what you want. What it will do is generate the file named login.txt which will contain the user name, computer name, time, and date. That file will then be copied to a folder that is named for the day of the week.

It's path looks like this as I used it:
C:\Documents and Settings\Owner\Desktop\SAT\login.txt

and the contents look like this:
Owner DON 23:10:50.42 Sat 12/13/2003
Owner DON 23:14:27.82 Sat 12/13/2003
Owner DON 23:15:15.07 Sat 12/13/2003
Owner DON 23:19:02.93 Sat 12/13/2003

It will require you to get the XXCOPY.EXE command which is a freeware utility. Although it is free, the particular switch being used to generate the day of the week is intended for corporate use and if you do not register the software, it will pause the batch and inform you how to prevent that pause. It will go ahead and run when you hit "Any Key" so it'll still function, just have that little nag.

Here's the code for what I have named login.bat
Code:
echo %username% %computername% %time% %date% >>"C:\Documents and Settings\Owner\Desktop\login.txt"
xxcopy /yy  "C:\Documents and Settings\Owner\Desktop\login.txt" "C:\Documents and Settings\Owner\Desktop\/$WWW$\"
You can learn more about XXCOPY and you'll appreciate its power in time (pun intended).

I think this actually accomplishes what you need since a new folder will be generated every day of the week. It will eventually write over the folders, so if you need to archive them, do so before the eighth day begins to preserve them. At that same time, you would want to delete the first login.txt file so as not to keep appending it forever. It will be recreated with the first run thereafter.

If all that maintenance is too much of a drag, I can add a couple more switches that will name the folder with the year and date, along with the day of the week. That would make it perpetual, without need to manually archive. The switch string would then look like this: /$YYYY-MM-DD-WWW$\ and the folder would be named like this: 2003-12-13-SAT. Great stuff, what?

Regards, Don.

Last edited by zephyr : 14-Dec-2003 02:56 AM.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:36 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.