Sign in to follow this  
Followers 0
WesW

Copy files to a remote machine

10 posts in this topic

Hello, I am new to AutoIt. I am trying to Copy a file from a server to a remote computer. i am hoping to make it work my putting the machine name in the inputbox and having the file copy. Can someone please help... it works file if I use this code

$Input1 = InputBox ("ProjectWise Dll", "AutoPLANT 2004","", "")

filecopy("Z:\Master\V8i_Start\acaddir1.bmp", "\\" & $Input1 & "\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup")

But I would like it to work with this gui...

[autoit]#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\wklw\My Documents\koda_1.7.3.0\Forms\Form1.kxf

$Form1_1 = GUICreate("Projectwise Bin", 319, 206, 202, 139)

$V8i = GUICtrlCreateInput("", 37, 108, 249, 21)

$Label1 = GUICtrlCreateLabel("AutoPLANT 2004", 44, 16, 105, 22)

GUICtrlSetFont(-1, 11, 400, 0, "Calibri")

$Label2 = GUICtrlCreateLabel("AutoPLANT V8i", 40, 83, 97, 22)

GUICtrlSetFont(-1, 11, 400, 0, "Calibri")

$Button2 = GUICtrlCreateButton("Copy", 119, 152, 81, 25)

$Input1 = GUICtrlCreateInput("", 37, 47, 249, 21)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Form1_1

Case $Label1

Case $Label2

Case $V8i

FileCopy("Z:\Master\V8i_Start\acaddir1.bmp", "\\" &$V8i& "\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup")

EndSwitch

WEnd

Share this post


Link to post
Share on other sites



Replace "Case $V8i" by "Case $Button2"

You want the button push to start the copy not the inputbox.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

I changed the case and the file still did not copy.. thanks

Case $Button2

FileCopy("Z:\Master\V8i_Start\acaddir1.bmp", "\\" & $V8i & "\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup")

EndSwitch

WEnd

Share this post


Link to post
Share on other sites

Maybe you will need the servername instead of Z:\ (in case you use netwerkconnection),

so i.e. FileCopy("\\servername\Master\V8i_Start\acaddir1.bmp", "\\" & $V8i & "\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup)


Many times you need to think like hobby-bob:')

Share this post


Link to post
Share on other sites

You need to use GUICtrlRead($V8i) for the location you want to copy to, not the handle to the inputbox. $V8i is the control id/handle to the control, not the contents of it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Can someone please give me an example to make this work. I am pulling my hair out! :)

See first post for details... Thanks for your help

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Form1_1

Case $Label1

Case $Label2

Case $Input1

EndSwitch

WEnd

Share this post


Link to post
Share on other sites

First of all, when posting code please enclose it in [ autoit] [/ autoit] tags so we can read it correctly, just remove the spaces in the tags, they're only there so that they show up on the page.

Second, unless you actually NEED to fire off events from the labels (Lable1, Label2) or from something on the GUI other than controls you don't need them in your switch statement.

Third, try this code in place of your code in post 3

Case $Button2
           FileCopy("Z:\Master\V8i_Start\acaddir1.bmp", chr(34)& "\\" & GUICtrlRead($V8i) & "\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" & chr(34))
EndSwitch

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Form1_1
        Case $Button2
           FileCopy("Z:\Master\V8i_Start\acaddir1.bmp", chr(34)& "\\" & GUICtrlRead($V8i)  & "\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" & chr(34))
EndSwitch

WEnd

I tried the above code and it did not work. any more suggestions. I also tried server name. If i place a machine name in the inputbox, does the GUICtrlRead($V8i) read what I put in the box and connect me to the remote machine.

Edited by WesW

Share this post


Link to post
Share on other sites

Try this in place of your whole While...Wend loop:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            $Source = chr(34) & "Z:\Master\V8i_Start\acaddir1.bmp" & chr(34)
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Source = ' & $Source & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
            $Destination = Chr(34) & "\\" & GUICtrlRead($V8i) & "\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" & Chr(34)
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Destination = ' & $Destination & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;~          FileCopy($Source, $Destination)
    EndSwitch
WEnd

Are you getting the output from the $Destination variable that you're expecting? If so, then you should be able to run this without a problem. If it doesn't copy the file then there is another issue unrelated to the script, probably a permissions problem, or the target computer is offline, or not running Windows Vista/7. You can uncomment the FileCopy line when you're sure the output is correct.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks for your help... I got it :)

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