Jump to content

Recommended Posts

Posted

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.

;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)

Posted

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.

Posted

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)

Posted

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)

Posted

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 network

Rick

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...