Jump to content

Robocopy


 Share

Recommended Posts

I have about 40 users throughout the domain who need to download to their laptops multiple folders. I don't want to have to create 40 different scripts. I have tested robocopy and this command works fine from the local command prompt.

C:\robocopy "\\server\share\<user name>" 'C:\clients" /s /z

What I need to do is replace the user name with the correct user. Can you use the $username function in this dos string?

It would also have to be used in the seperate upload script in the same fashion.

Link to comment
Share on other sites

I have about 40 users throughout the domain who need to download to their laptops multiple folders. I don't want to have to create 40 different scripts. I have tested robocopy and this command works fine from the local command prompt.

C:\robocopy "\\server\share\<user name>" 'C:\clients" /s /z

What I need to do is replace the user name with the correct user. Can you use the $username function in this dos string?

It would also have to be used in the seperate upload script in the same fashion.

<{POST_SNAPBACK}>

You could execute the program from an AutoIt script, and using the & operater put your variable.

Example:

$Adj = "Ugly"
$Text = "You fat "&$Adj&" dog!"

The end result:

Text = You fat ugly dog.

Therefore, assuming your using v3, you just use the Run command with @Comspec and execute that tingy wingy and use the @SW_HIDE with it too, and uh.........

yea.

You should get it by now, if you look at the help file a bit.

If not, your a moron. just kidding.

I used to have over 700 posts. This is a new account. I am not a newbie.My AutoIt Home Page - Here is all my AutoIt stuff. Well, actually, I have loads more, I am just too lazy to put it on my page right now so deal with it.Guess what? The unvierse is made out of basically nothing.Think about it? What is the smallest building block of anything, it is what? A chunk of nothingness. Thats all. Hey this peice of space is a forperborb and it is so.
Link to comment
Share on other sites

I have about 40 users throughout the domain who need to download to their laptops multiple folders. I don't want to have to create 40 different scripts. I have tested robocopy and this command works fine from the local command prompt.

C:\robocopy "\\server\share\<user name>" 'C:\clients" /s /z

What I need to do is replace the user name with the correct user. Can you use the $username function in this dos string?

It would also have to be used in the seperate upload script in the same fashion.

<{POST_SNAPBACK}>

First things first: Ignore Guido and his pathetic attempt at an insult and a RTFM post.

Second: RunWait(@ComSpec & " /c " & "commandName")

If your system sets the environment variable %USER% as the username, you can get it from there:

$username = EnvGet("USER")

RunWait(@ComSpec & " /c " & 'C:\robocopy "\\server\share\' & $username & '" "C:\clients" /s /z')

Or you can get it from the @UserName macro.

RunWait(@ComSpec & " /c " & 'C:\robocopy "\\server\share\' & @UserName & '" "C:\clients" /s /z')

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Good job blue drache, I was trying to help, but I couldn't explain too well.

@The first person who posted:

I hoped that helped you.

That is exactly what I was trying to post, only he explained in more in good detail.

Edited by Guido
I used to have over 700 posts. This is a new account. I am not a newbie.My AutoIt Home Page - Here is all my AutoIt stuff. Well, actually, I have loads more, I am just too lazy to put it on my page right now so deal with it.Guess what? The unvierse is made out of basically nothing.Think about it? What is the smallest building block of anything, it is what? A chunk of nothingness. Thats all. Hey this peice of space is a forperborb and it is so.
Link to comment
Share on other sites

$username = EnvGet("USER")

RunWait(@ComSpec & " /c " & 'C:\robocopy "\\server\share\' & $username & '" "C:\clients" /s /z')

When I run this line of script as written, I get a brief flash of a dos window and no data is copied from the server share to the local machine. I also get the same response running the second suggestion. I think this might be due to the fact that the dos prompt does not open to the local users C:\ but rather to their shared network Z:\ drive. Can the @SystemDir macro be used here?

Link to comment
Share on other sites

When I run this line of script as written, I get a brief flash of a dos window and no data is copied from the server share to the local machine. I also get the same response running the second suggestion. I think this might be due to the fact that the dos prompt does not open to the local users C:\ but rather to their shared network Z:\ drive. Can the @SystemDir macro be used here?

<{POST_SNAPBACK}>

You could try, but it shouldn't happen if we're telling the script to run robocopy from the C:\.

Is robocopy on the default path?

The dos window flash can be fixed by adding a ,"",@SW_HIDE) to the end of the command. Just remove the closing parenthesis first and tack on everything that I bolded/italicized. I forgot about that earlier.

RunWait(@ComSpec & " /c " & 'C:\robocopy "\\server\share\' & $username & '" "C:\clients" /s /z',"",@SW_HIDE)
Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

RunWait(@ComSpec & " /c " & 'C:\robocopy "\\server\share\' & $username & '" "C:\clients" /s /z',"",@SW_HIDE)

Adding this to the end of the statement produces the error "Unable to execute the external program. The directory name is invalid.

Link to comment
Share on other sites

I normally have my scripts on a network share. Users are pointed to this share to execute the script. I've noticed that when I execute this script from the network share, robocopy picks up a portion of the network share as part of the destination address so instead of C:\legecy clients it becomes z:\Autoit test\clients \s \z. Is there a way to construct the script to start at the C:\?

I moved the script to the local machine and robocopy adds that local address to the destination path.

Link to comment
Share on other sites

I normally have my scripts on a network share. Users are pointed to this share to execute the script. I've noticed that when I execute this script from the network share, robocopy picks up a portion of the network share as part of the destination address so instead of C:\legecy clients it becomes z:\Autoit test\clients \s \z. Is there a way to construct the script to start at the C:\?

I moved the script to the local machine and robocopy adds that local address to the destination path.

<{POST_SNAPBACK}>

No idea. I'll have to look at the batch files that we use here....

That's another option, use a .bat file instead....but that's last resort. There should be a way to do it within AutoIt, but I'm fresh out of ideas at this point.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

try...

RunWait( 'C:\robocopy "\\server\share\' & @UserName & '" "C:\clients" /s /z', 'c:\', @SW_HIDE )

Lar.

<{POST_SNAPBACK}>

*sigh* Leave it to me to find every solution but the simple one.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...