Jump to content

Deploying script to remote systems


mrjhay
 Share

Recommended Posts

I have a Autoit script that I need to deploy to a large number of systems, preferrable by connecting to the group of systems in the OU. Right now, it works on a local machine. Do anyone have a solution that works and perform a query to list the systems that completed successfully?

Link to comment
Share on other sites

You only want to copy the specified file / directory to a remote system?

I started working on an application for mass deployment of files a while ago, the idea being to deploy entire program direcotory stuctures (for apps that dont need reg keys)

or configuration files when updates are made, eitherway, the code for it is attatched.. perhaps it might be good as a basis for you, we have a program called Net Support Schools now, and i can use it to transfer / execute applications remotely, so i dont need this any more, but it would still be great to be able to push out and remotely execute applications / scripts (other than using the login scripts to do it)

This is designed for our systems, where a computer is named:

site-room-pcnumber

ie:

NORTH-Room1-01 to NORTH-Room1-30

with an optional

-brand (-D for dell, -AV for Acer Veriton, we used to do this to remember what brand was where.. but it is no longer needed, you can ignore this field)

but it is still designed to do batches of computers.. and may (most likely) not fit your exact situation..

here is the code i have:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.1.1.0
 Author:         tAKTelapis (aka: tAK)
 Contact:    www.onewaylan.com

 Script Function: Copy files or directories to remote systems

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#NoTrayIcon
#Include<GUIconstants.au3>

GuiCreate("Copy Files", 350, 350)
GUISetState (@SW_SHOW)

GUICtrlCreateLabel("Prefix:", 25, 10)
$prefix = GUICtrlCreateInput("", 25, 25, 100, 25)
GUICtrlCreateLabel("# Systems:", 150, 10)
$NumberOfSystems = GUICtrlCreateInput("", 150, 25, 75, 25)
GUICtrlCreateLabel("Suffix:", 250, 10)
$Suffix = GUICtrlCreateInput("", 250, 25, 75, 25)
GUICtrlCreateLabel("Drive:", 25, 60)
$Drive = GUICtrlCreateInput("", 25, 75, 75, 25)
GUICtrlCreateLabel("File or Directory Copy?", 150, 60)
$FileCHK = GUICtrlCreateCheckbox("File", 150, 80)
$DriveCHK = GUICtrlCreateCheckbox("Directory", 225, 80)
GUICtrlCreateLabel("File or Directory To Copy:", 25, 115)
$File = GUICtrlCreateInput("Input File / Folder path here without a trailing \", 25, 130, 300, 25)

$btn_OK = GUICtrlCreateButton("OK", 275, 300, 50, 25)
$btn_Help = GUICtrlCreateButton("Help", 200, 300, 50, 25)


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $btn_Help
            MsgBox(0, "Help", "Only tick File OR Directory, NOT both")
        Case $msg = $btn_OK
            if GUICtrlRead($FileCHK) = 1 then
                MsgBox(0, "you are copying a file", "you are copying a file")
                For $i = 1 To GUICtrlRead($NumberOfSystems) Step 1
                    if StringLen($i) = 1 then
                        $i = "0"&$i
                    EndIf
                    $LocalPathLength = StringLen(GUICtrlRead($file))
                    $LocalPathLength = $LocalPathLength - 2
                    $DestinationPath = StringRight(GUICtrlRead($file), $LocalPathLength)
                    FileCopy(GUICtrlRead($file), "\\"&GUICtrlRead($prefix)&$i&GUICtrlRead($Suffix)&"\"&GUICtrlRead($drive)&'$'&$DestinationPath, 9)
                Next
                MsgBox(0, "Copy Complete", "no error checking at this stage")
                ExitLoop
            ElseIf GUICtrlRead($DriveCHK) = 1 then
                MsgBox(0, "you are copying a directory", "you are copying a directory")
                For $i = 1 To GUICtrlRead($NumberOfSystems) Step 1
                    if StringLen($i) = 1 then
                        $i = "0"&$i
                    EndIf
                    $LocalPathLength = StringLen(GUICtrlRead($file))
                    $LocalPathLength = $LocalPathLength - 2
                    $DestinationPath = StringRight(GUICtrlRead($file), $LocalPathLength)
                    DirCopy(GUICtrlRead($file), "\\"&GUICtrlRead($prefix)&$i&GUICtrlRead($Suffix)&"\"&GUICtrlRead($drive)&'$'&$DestinationPath, 1)
                Next
                MsgBox(0, "Copy Complete", "no error checking at this stage")
                ExitLoop
            EndIf
    EndSelect
WEnd
Link to comment
Share on other sites

If you don't mind stepping outside of Auto IT, I would suggest the PSinternals package along with Robocopy, both are free MS tools (now that MS bought Sysinternals). You can write an auto IT macro for this I'm sure, but I generally just use DOS batch files (I know, <shudder>)

Get the PS tools pack - you can execute a command on every machine on the domain using a * wild card.

http://www.microsoft.com/technet/sysintern...es/pstools.mspx

Specifically look at http://www.microsoft.com/technet/sysintern...ies/psexec.mspx

You should write your command to execute robocopy first on the remote machine - Get Robocopy from:

http://download.microsoft.com/download/8/e...057/rktools.exe - install the pack

If I were you, I'd write a DOS batch command to run in this order - you'll execute it via the pxexec command.

The psexec command will execute the same batch file on every PC on the domain, one at a time, so write a batch file that compliments that -

The batch should:

copy the robocopy command to the remote PC

Execute it and copy down whatever file you need to install

Execute the file install via command line

(Reboot if needed using PSshutdown)

When you code this, remember that everything needs to execute silently, which will probably be done with DOS commandline switches.

Lastly, both this version of robocopy and the PSinternal tools will work with Windows 2K, XP, 2k3, and Vista - no win9x, and probably no winnt.

Hope this helps.

Jim

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...