emmanuel Posted June 13, 2004 Share Posted June 13, 2004 I wrote this to replace a batch file the users have that copies files from the network and then launches them locally, to avoid locking the file on the network... this is my first time putting SetError and Return in a script, and I haven't tested that part yet. expandcollapse popup;copy file local, then launch with specified app ;get app path from registry ; $appname is the file.exe of the program to launch the copied file, ; $source is the folder to copy from, no trailing backslash ; $filename is the name of the file to copy, ; $target is the target folder to copy to, no trailing backslash ; $runmethod should either be Run or RunWait ; $overwrite is 1 to overwrite, 0 not to. ; errorlevel 0 if something didn't work right ; return value: ; 0 if error ; 1 if successful ;example use: $SERVERPATH = "\\server\share\path to file" $LOCALPATH = "C:\local_working_dir" _copylaunch("msaccess.exe", $SERVERPATH, "AccessDB.mdb", $LOCALPATH, "RunWait", 1) Func _copylaunch($APPNAME, $SOURCE, $FILENAME, $TARGET, $RUNMETHOD, $OVERWRITE) If FileCopy($SOURCE & "\" & $FILENAME, $TARGET & "\" & $FILENAME, $OVERWRITE) = 0 Then SetError(0) EndIf $_APPPATH = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" & $APPNAME, "") If $_APPPATH = 1 Then SetError(0) If $RUNMETHOD = "RunWait" Or $RUNMETHOD = "" Then RunWait($_APPPATH & " " & '"' & $TARGET & "\" & $FILENAME & '"') ElseIf $RUNMETHOD = "Run" Then Run($_APPPATH & " " & '"' & $TARGET & "\" & $FILENAME & '"') Else SetError(0) Return (0) EndIf EndFunc ;==>_copylaunch "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
ezzetabi Posted June 16, 2004 Share Posted June 16, 2004 Doesnt Psexec already do that? I use PSexec to exectuce the file (and coping it) and after (the runwait, I mean) the autoit scrip tries to delete the file and it tries until it deleted them all. Link to comment Share on other sites More sharing options...
emmanuel Posted June 16, 2004 Author Share Posted June 16, 2004 PSexec? not familiar. I don't want to delete the files after they're run... "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Josbe Posted June 16, 2004 Share Posted June 16, 2004 PsExec <-- AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
emmanuel Posted June 16, 2004 Author Share Posted June 16, 2004 looks like psexec is not quite what I'm looking for... I'm not looking to push exe's to other computers (that's cool though) I'm looking to allow people to run a script to copy files locally then open them with the specified app. We've got some files that don't like to be open by multipule users at one time, yet we need multipule people to be able to open them... "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
tutor2000 Posted June 17, 2004 Share Posted June 17, 2004 looks like psexec is not quite what I'm looking for... I'm not looking to push exe's to other computers (that's cool though) I'm looking to allow people to run a script to copy files locally then open them with the specified app. We've got some files that don't like to be open by multipule users at one time, yet we need multipule people to be able to open them...I'm trying that with a salesreportgenerator to speed stuff up. It takes forever over the networkRick Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now