Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
#DefineFunction copyfile(pathfrom, pathto, filename, newname) IntControl(73, 2, 0, 0, 0) If newname == "" Then newname = filename If !FileExist(StrCat(pathto, newname)) If !DirExist(pathto) Then DirMake(pathto) If StrSub(pathto, StrLen(pathto), 1) != "\" && StrSub(newname, 1, 1) != "\" Then pathto = StrCat(pathto, "\") If StrSub(pathfrom, StrLen(pathfrom), 1) != "\" && StrSub(filename, 1, 1) != "\" Then pathfrom = StrCat(pathfrom, "\") FileCopy(StrCat(pathfrom, filename), StrCat(pathto, newname), @false) EndIf Return #EndFunction IntControl(73, 2, 0, 0, 0) retour = copyfile("c:\", "c:\test", "cdscdscv.doc", "*.bak") Exit :WBERRORHANDLER erreur = LastError() Select erreur Case 1008 erreur = StrCat(erreur, " FileCopy: Failed") Break Case 1009 erreur = StrCat(erreur, " FileCopy: FROM file open failed") Break Case 1010 erreur = StrCat(erreur, " FileCopy: TO file open failed") Break Case 1011 erreur = StrCat(erreur, " FileCopy: I/O error") Break Case 0 Break Case erreur erreur = StrCat(erreur, " Autre erreur") Break EndSelect Message("", erreur) IntControl(73, 2, 0, 0, 0) Return
I need to suppress all error messages because i'm running those scripts "underground" via tivoli (just like a psexec command sent to a remote pc) and if there is a popup, the script just hangs and stay in the memory forever.
Usually i don't do a "message" on the error like in the example script i posted but i log it in a txt file on the local disk.
It's working great but it's the first time i try to run this with a definefunction.
Article ID: W15980
File Created: 2004:03:30:15:42:06
Last Updated: 2004:03:30:15:42:06