General discussion

Locked

AT bat script

By NetWill ·
I need to a script that runs from 8 - 5PM. This is what it suppose to do:

1- Run from NTSVR1.

2- Check for a filename (ie. test.log) under certain directory on WKS1 to see if it exists. If exists, check if accessible(not locked/using).

2- If accessible, rename \\NTSVR1\dir\test.log to \\NTSVR1\dir1\test0407200.log.

3- Copy \\WKS1\dir\test.log to \\NTSVR1\dir\test.log.

Any ideas on how to accomplish this?

Appreciate any info!

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

AT bat script

by simon.wellborne In reply to AT bat script

Hello.
Without writing the script for you - here are some ideas.

rem check for file on wks1
if exist \\wks1\sharename\filename check to see if it is locked. There maybe a util for this, but what I would do is try and rename the file to something else. If it fails then the file is locked, if it succeeds then copy it to server.

Ren \\ntsvr1\dir\test.log to new name

Copy \\wks1\dir\test.log etc

This is using NT batch commands, so you can use the copy command with UNC names.

Doing the rename is the easiest mehtod to check for file lock. Use the errorlevel result to check for failure etc.

Good luck. Sorry I couldn't write it for you, but no way of testing.

Collapse -

AT bat script

by NetWill In reply to AT bat script
Collapse -

AT bat script

by TrentCook In reply to AT bat script

here is a snip from my avirus batch script:

@echo off
rem ********************************************************
net use v: \\servername\virus$ /yes

if exist "c:\vupdate" goto :next
md "c:\vupdate"

:next

if exist "c:\vupdate\vupdate.exe" deltree /y "c:\vupdate\vupdate.exe"
cls

if not exist "C:\Program Files\InoculateIT PE\vet98.exe" goto :END

if exist "c:\vupdate\march6.txt" goto :END

goto :update

it works great.
HTH

Trent Cook
MCSE, MCP+I, CNA, A+

Collapse -

AT bat script

by NetWill In reply to AT bat script
Collapse -

AT bat script

by timgray In reply to AT bat script

There is a very easy way to do this, and there is a book written about it! O reilly and associates published a book called Windows NT workstation Configuration & maintaince. it uses the Perl language to overcome the horrible limitations that NT imposes on scripting. I have a script that runs every night that looks to see if it's collection of tool scripts have newer versions (Via a version=4 statement in the scripts themselves) and then executes the scripts. As for something that runs all day I use a script that is running as an NT service (The book tells you how to do that also)

ISBN 1-56592-613-7 $24.95 USD

I reccomend this book to every NT sysadmin, it makes life very easy.

Collapse -

AT bat script

by NetWill In reply to AT bat script
Back to Windows Forum
6 total posts (Page 1 of 1)  

Related Discussions

Related Forums