Hello All.

I am trying to get a pull a text file from each client computer for an audit.  It seems fairly straight forward until I think you run into share permissions.  I can easily get a file to the client but am having a hard time pulling a file.  Here is the .bat file that I used:

CD C:\
CD APS
COPY TICKET.TXT C:\SOIT
CD C:\
CD SOIT
REN TICKET.TXT %COMPUTERNAME%.TXT

COPY *.TXT Z:\
EXIT

** ticket.txt is move to another directory so not to modify the file that is in use.

** after it is moved then it is named

The bat file fails (does not complete but no message) on the copy *.txt z:\ using the K1000 scripting method.

It works when I run the .bat from the command line on the computer.  Does anyone have an good ideas on how to pull a file to a network share?

Thanks for your help.

Answer Summary:
Thank you JordanNolan. The UNC path for the share was the answer.
Cancel
1 Comment   [ + ] Show Comment

Comments

  • Is the file you are trying to copy in use by a particular process? Where the file is being stored (the Z drive) does the user have permission to copy something there?
Please log in to comment

Answers

1

Instead of using Z:\  you need to use the UNC path.  The KACE agent runs as the system account (unless you say otherwise) and the system account is not mapped to any drive.  Change Z:\ to \\servername\sharename and be sure that it is open for RW for Everyone or at least make sure your security allows the computer account to access the share.  Keep in mind "Domain users" are user only, not computers.

Also it looks like you are just trying to copy one file to another local folder and to the share. You can do that in two steps.

COPY C:\APS\TICKET.TXT C:\SOIT\
COPY C:\APS\TICKET.TXT 
\\Servername\ShareName\%COMPUTERNAME%.TXT
EXIT

Things to keep in mind is the share path needs to be in quotes if there are spaces in the name.  Also if the file exists and you try to overwrite it you will need to answer the prompt to overwrite. You can do that with an Echo Y statement like this:

Echo Y|COPY C:\APS\TICKET.TXT \\Servername\ShareName\%COMPUTERNAME%.TXT

 

 

Answered 06/20/2014 by: JordanNolan
Third Degree Black Belt

Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share