I am trying to write a procedure to a file from a local machine to another location based on the logged user using the xcopy command.
So far, this is what i have done.
xcopy c:\"documents and settings"\%username%\desktop\*.yyy \\somenetworkloccation\folder\%username%\
I tried this command from the command prompt and it works fine but the procedure doesnt seem to work although it states that its successful.
i tested it on a machine that has somebody currently logged in and a logged off machine. same result.
As far as kaseya is concerned - it did run the script.. It wont pick up errors in the shell command.. You will have to do something like
xcopy c:\"documents and settings"\%username%\desktop\*.yyy somenetworkloccation\folder\%username%\ >> C:\temp\result.txt
then read that text into a variable and test that variable or write it to the log.. You can also just look at the file to see what error you are getting in the command line and fix your statement from there...
I would suggest you test this in a command window - I have a feeling its where your quotes are.. Try to do this command
xcopy c:\documents and settings"\%username%\desktop\*.yyy" "\\somenetworkloccation\folder\%username%\"
oops I messed that up
xcopy "c:\documents and settings\%username%\desktop\*.yyy" "\\somenetworkloccation\folder\%username%\"
that should do it
I have scripts doing this successfully. I had to specify using a credential that is valid on both machines, and run the command as logged in user.
^ good point @jmossburg
@ Paul - I did have the right syntax DOS syntax for xcopy. The command i showed here was for the K procedure. I'll try your suggestion to output the result to a file. Thanks.
@ jmossburg - Unfortunately it will be difficult to use a common credential because this will be deployed/used for all users or at least 25 credentials. Thanks.
When running a Kscript with Excute Shell command it needs to display the same as if you were typing it into CMD.
Thanks Everyone for all the responses. i got it working, i was only able to troubleshoot after outputting the result to a file (Paul).
Glad to hear it!