Jump to content

Program to copy files; runs from web link


Recommended Posts

I have a small copy script that is on a web server. The script copies two file from the server to the users local PC. (The plan is to send the link in an email and have the users open the web page and run the program.)

I have used FQDN to identify where to find the files to be copied. I would like to change that FQDN to something a little more forgiving (so I dont have to change the code and recompile every time the files may get moved around) but everything I have tried failed.

I am including in the code the commented line(s) that does not work, above it is the one that does. If the Func _FileCopy looks familiar, its the short and sweet Windows copy progress bar. So much good stuff on this forum :)

RunAsSet("administrator", @computername, "password")

$copy = _FileCopy("\\servername.domain.com\sharename\program.exe","C:\temp\")
;$copy = _FileCopy(@ScriptDir & '\program.exe","C:\temp\")

Func _FileCopy($fromFile,$tofile) 
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)
EndFunc

While ProcessExists($copy)
    Sleep(50)
Wend

$copy2 = _FileCopy2("\\servername.domain.com\sharename\program2.exe", @UserProfileDir & "\desktop")
;$copy2 = _FileCopy2(@ScriptDir & "\program2.exe", @UserProfileDir & "\desktop")

Func _FileCopy2($fromFile,$tofile) 
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)
EndFunc

While ProcessExists($copy2)
    Sleep(50)
Wend
MsgBox(0, "Done", "Files have been copied to your desktop. Please " & @CRLF & _
"go to your desktop and double click program2.exe")
;Run("C:\temp\setup.exe")

RunAsSet()

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

You could just pack those two files into your compiled AutoIt executable with FileInstall(). Then they simply run your .exe and it will put the files where you want them. At compile time, your script needs a valid literal path to the source files. But at run time, it only needs a valid destination.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Interesting idea. My only concern is running this across my WAN. Some of our links are pretty slow; thats the purpose of the progress bar, to let users know that the program is still running and they shouldn't log off or kill the app.

Using the method you suggest, how could I alert the end user that the program is still running?

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

I think the way PsaltyDS said it, you'd FileInstall your program.exe and program2.exe into the file they would download from the webserver, so the only slowness they would see would be the time it took to download the main program. After it's downloaded, program.exe and program2.exe would be file installed instantly (given they had chosen open this link), so all you'd have to do is alert them that the file is there, and they can run it when ready.

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