Sign in to follow this  
Followers 0
carpediem

Calling Robocopy from a startup script

4 posts in this topic

#1 ·  Posted (edited)

I'm trying to achieve a folder syncronization from one of our servers to domain computers using a startup script (Running as local system) but I run into problems.

The problem

Login scripts that require admin rights doesn't work on Vista/Windows .

The solution

Run user logon scripts as before but move stuff that require admin rights into a startup script wich runs with Local System credentials

Here's what's happening

The autoit3.exe is called from the startup script section in a GPO with the location of the script called as a parameter. This works fine and I've tested to create a file from the script and it lands on the remote computer just fine. I run into problems when I call robocopy to do its stuff. Running the script (with admin rigths) while logged in, it works fine, but when the script runs on startup Robocopy doesn't do anything.

If anyone has an idea on why it doesn't work, I'd be very greatful. Is it that RoboCopy can't be called at all during a startup process (pre login)?

Here's the script:

$sBaseServerFolder = "\\fileserver\share\"
$sBaseComputerFolder = "c:\localFolder\"
$saCopyFolders = StringSplit("Folder1,Folder2,Folder3,FolderX",",")

for $i = 1 to $saCopyFolders[0]
    $sCopyString = $sBaseServerFolder & $saCopyFolders[$i] & ' ' & $sBaseComputerFolder & $saCopyFolders[$i]
    Run(@ScriptDir & '\robocopy.exe' & ' ' & $sCopyString & ' /S /E /R:0 /W:0', "", @SW_HIDE)
Next
Edited by carpediem

Share this post


Link to post
Share on other sites



Hi carpediem,

I guess you "local system" has no access to \\fileserver\share.

Either you grant access for the Computer object to that folder, or you can try to do a DriveMapAdd() with given credentials before you run the robocopy.


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi carpediem,

I guess you "local system" has no access to \\fileserver\share.

Either you grant access for the Computer object to that folder, or you can try to do a DriveMapAdd() with given credentials before you run the robocopy.

I Hannes and thanks for the tip.

The test machine already has access to read autoit3.exe, the script and robocopy.se (all files are in the same folder in the sysvol share for the startup script)

Edited by carpediem

Share this post


Link to post
Share on other sites

If anyone has tips, it would be greatly appreciated.

Share this post


Link to post
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
Sign in to follow this  
Followers 0