1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

{advice offered} - Another scripting question....

Discussion in 'Windows XP' started by jharrison, Feb 8, 2000.

Thread Status:
Not open for further replies.
Advertisement
  1. jharrison

    jharrison Thread Starter

    Joined:
    Mar 3, 1999
    Messages:
    129
    here i am again. i got the script to work. it copies a file from a server into the local systemroot directory. it works perfectly. now i have an extension i want to add to this.

    i want to know when it copies the file whether or not the file already exists. if it does then it can go ahead with the copy. if not then i want it to not copy the file and to somehow let me know that it doesn't exist on the computer (via a dump into a file, an email, anything). now this is going to be run on 350+ computers so i'll need to know which computer it came from, too (computer name or username will work). we're just using a batch file, no windows scripting host or anything fancy. i don't believe anyone here knows how to script in WSH anyway.

    another option could be for it to check for the file, and if it finds it go on with the copy. if not then pause and present a message to the user asking them to call the helpdesk and tell me that they don't have the program installed.

    at any rate, i obviously don't know where to start with this one. i would really appreciate any help/ideas on what would be best and how to go about it. thanks in advance!
     
  2. MikeB

    MikeB

    Joined:
    Apr 6, 1999
    Messages:
    186
    sorry about all the edits. i am having a hard time getting this to read right.

    You can use the “ if exist “ condition in the logon script

    syntax- if exist filename command. where filename is the name of the file you are looking for to include the path and where command is the command to execute if the file exist.

    in your case it would be

    if exist %systemroot$\filename copy filename %systemroot%\filename

    use “if not exist” with the "net send" command to receive a message on your computer (nt I hope).

    For more info on "net send" type net send at an NT dosprompt

    The %computername% will append the computer name the logonscript is running on to the net send message. .

    so you can use something like this-

    if not exist filename net send yourmachinename filename on %computername% is not available.


    You can call on a batch file from the logon script, ie add a line

    call copyfile.bat

    in the copyfile.bat include the above mentioned method.

    [This message has been edited by MikeB (edited 02-08-2000).]

    [This message has been edited by MikeB (edited 02-08-2000).]
     
  3. jharrison

    jharrison Thread Starter

    Joined:
    Mar 3, 1999
    Messages:
    129
    MikeB, thx for the info. it looks like it will definitely help. i understood everything up to the call section. i don't get it. what would i use that for?
     
  4. MikeB

    MikeB

    Joined:
    Apr 6, 1999
    Messages:
    186
    The call section will just help clean up the logon script so you call on the copy file and edit it as needed instead of getting all cluttered up in the logon script.
     
  5. jharrison

    jharrison Thread Starter

    Joined:
    Mar 3, 1999
    Messages:
    129
    if i understand you right, the copy file will be sort of an "extra" script that is called by the logon script to run, right?
     
  6. MikeB

    MikeB

    Joined:
    Apr 6, 1999
    Messages:
    186
    Yes, that is correct. It is useful when you have logon scripts that do a lot, when you want to give some administrators rights on parts of the loginscripts but not others, or just to help keep the functions divided. If you are not using a batch file but rather some other script file the “if [not] exist” function may not work. So the call might be how you would implement this “if [not] exist” condition. The call is not required to use the "if [not] exist” condition. The "if [not] exist" condition will work in any batch file.

    [This message has been edited by MikeB (edited 02-08-2000).]

    [This message has been edited by MikeB (edited 02-08-2000).]
     
  7. jharrison

    jharrison Thread Starter

    Joined:
    Mar 3, 1999
    Messages:
    129
    one more thing, MikeB. i know the net send would work, but do you know of a way to do it so that the information would dump into a file, or to have an email sent to a specific address with specific information about the user's pc (namely machine name or username)? it would work better that way then with net send. thx for all your help.
     
  8. Reuel Miller

    Reuel Miller

    Joined:
    Feb 17, 1999
    Messages:
    1,821
    Greetings

    You can use the fact that you can echo text to a file, and append more text onto an already exisitng file.

    So, you can use a command like this:

    echo %computername%, %username%>>\\servername\sharename\logon.csv

    This way, it will create a comma deliminted file that you can view in Excel.

    So, the full command line will read like:

    if not exist filename echo %computername%, %username%>>\\servername\sharename\logon.csv




    ------------------
    Reuel Miller
    Windows NT Moderator (yes, that does make me biased :) )

    [email protected]

    Every morning is the dawn of a new error...
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/28306

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice