Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

batch file help to check for file existence

Status
Not open for further replies.

tinito

Technical User
May 21, 2004
32
GB
Hi all,

i am really new to writing batch files.
was wondering if you could please help me with the following...

scenario is as follows:

my boss has asked me to write/incl some batch code in our login script that must see if a file does NOT exist on a users pc (ie. an exe)

if the file(exe) does NOT exist, it must write the pc hostname to a text file on a server share for him to review.
at the same time, if possible,it must copy the missing file down from the server and if possible pipe out a succesful copy result to another text file.
he mentioned errorlevels to me, which doesnt make much sense to me.

an example of the above scenario would be: c:\winnt\test.exe


hope you guys can help me with this.

regards,
Tinito
 
Open a command prompt and type:

help if

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
you guys havent been very helpful.

i dont know much about batch scripting so therefore i am asking for some help?

i know i can type in: help if in a cmd prompt BUT that still doesnt explain to me how i can pipe out to a text file?

i know how to check for file existence, but how do i write the hostname to a text file etc etc.

Tinito
 
You will get various different opinions on this, but since I am getting no renumeration for any assistance I give you, then I'm being very helpful in terms of the expense to you.

In your original post, you specifically mention errorlevels and the help file that I pointed you to deals specifically with error levels.

In the big picture, I don't think you will find a lot of people here that will write your batch file for you. If you have something already written and you are looking for help with a specific problem, that is a completely different issue. Post the code and ask about the specific question.

A search on google for 'batch file output to text file' produced several results. The first page returned skirts around the answer to your question about how to pipe to a text file while the second page returned has an explicit example of doing exactly that.


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top