Is there a way to create a custom copy action?

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
DelphiDev
Junior Member
Junior Member
Posts: 14
Joined: 2019-03-22, 12:03 UTC

Is there a way to create a custom copy action?

Post by *DelphiDev » 2019-07-05, 06:28 UTC

Hey there,

many times a day I copy a build output from our build share to my local %programfiles% and overwrite all existing files.
So I need to
  • Ctrl + A (Select all files from folder in left panel)
  • F5 (copy selected files to folder in right panel)
  • Return (Confirm copy)
  • Alt + A (Overwrite all files)
  • Alt + L (All as Administrator)
  • Y (confirm UAC)
Is there a way to encapsulate these steps into a single action? (UAC will still be necessary, I know and I can live with that)

Thanks

vdijken
Junior Member
Junior Member
Posts: 80
Joined: 2016-07-30, 14:07 UTC
Location: The Netherlands

Re: Is there a way to create a custom copy action?

Post by *vdijken » 2019-07-05, 09:17 UTC

Synchronize directories?

DelphiDev
Junior Member
Junior Member
Posts: 14
Joined: 2019-03-22, 12:03 UTC

Re: Is there a way to create a custom copy action?

Post by *DelphiDev » 2019-07-05, 09:29 UTC

I figured that a batch file would be the easiest way to accomplish this.
So I created a batch file test.bat

Code: Select all

xcopy %1 %2 /O/X/E/H/K
I then created a new button in TC.
Command: *D:\test.bat (* for elevation)
Parameters: "%P" "%T" (%P source dir, %T target dir)

Clicking the button however does not execute the batch file. When I omit the quotation marks the batch file executes as expected, with the quotation marks the batch file does not seem to be executed. I even added "pause" to the end of the batch but it doesn't pause hence was not executed at all. (cmd window opens and closes directly)

When I omit the * to elevate the batch, the quoted parameters work. (tested with echo %1) But since I need elevation to be able to write to %programfiles% I need the *.

Is there a bug with starting a batch elevated and quoted parameters?

User avatar
norfie²
Power Member
Power Member
Posts: 838
Joined: 2006-02-10, 07:27 UTC

Re: Is there a way to create a custom copy action?

Post by *norfie² » 2019-07-05, 09:49 UTC

This doesn't need a batch file. Xcopy can be used directly.
"War is evil, in so far as it makes more bad people than it takes away."
Immanuel Kant in "Perpetual Peace"

User avatar
Stefan2
Power Member
Power Member
Posts: 2643
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Is there a way to create a custom copy action?

Post by *Stefan2 » 2019-07-05, 09:58 UTC

DelphiDev wrote:
2019-07-05, 09:29 UTC
Is there a bug with starting a batch elevated and quoted parameters?
User and elevated admins are different user accounts. So,... what is your target dir?
Try to launch a cmd window and there try to browse to source and target folders,... are they available for the elevated user?

You can also use ""RunAs" in your batch:
runas /user:you xcopy %1 %2 /O/X/E/H/K



Or try like norfie² mentioned:
Command: *xcopy
Parameters: "%P" "%T"




 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

User avatar
norfie²
Power Member
Power Member
Posts: 838
Joined: 2006-02-10, 07:27 UTC

Re: Is there a way to create a custom copy action?

Post by *norfie² » 2019-07-05, 10:49 UTC

Mark the text below, copy to clipboard and paste as button into the button bar.

Code: Select all

TOTALCMD#BAR#DATA
*%SystemRoot%\System32\xcopy.exe
"%P". "%T". /EHKOX
totalcmd.exe,2
Xcopy with Admin


-1
"War is evil, in so far as it makes more bad people than it takes away."
Immanuel Kant in "Perpetual Peace"

DelphiDev
Junior Member
Junior Member
Posts: 14
Joined: 2019-03-22, 12:03 UTC

Re: Is there a way to create a custom copy action?

Post by *DelphiDev » 2019-07-05, 11:51 UTC

Thanks @ all.
I'm still struggling to find the culprit.
Can I somehow pipe the output to a text file?
adding " > d:\output.txt" to the parameters doesn't work as expected. (Yes, D: exists and I can write there)

User avatar
norfie²
Power Member
Power Member
Posts: 838
Joined: 2006-02-10, 07:27 UTC

Re: Is there a way to create a custom copy action?

Post by *norfie² » 2019-07-05, 12:16 UTC

2DelphiDev
Did you test my button? (I tested it and it works for me like a charm :D)
There is a problem with admin account and path variable. You need to specify the whole path to xcopy.exe.
Another problem are the backslash signs in the end of the source path and target path. Xcopy don't like that therefore I putted a dot at the end of source path and target path. If you don't like that you could put a file mask with asterisks *.* at each end of paths.
Last edited by norfie² on 2019-07-05, 12:27 UTC, edited 2 times in total.
"War is evil, in so far as it makes more bad people than it takes away."
Immanuel Kant in "Perpetual Peace"

User avatar
Stefan2
Power Member
Power Member
Posts: 2643
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Is there a way to create a custom copy action?

Post by *Stefan2 » 2019-07-05, 12:19 UTC

DelphiDev wrote:
2019-07-05, 11:51 UTC

Can I somehow pipe the output to a text file?
Which "output"? What you're talking about now exactly? (my crystal bowl is broken)

What do you want to output? StdOut? StdErr? Try ....1&2> d:\output.txt"...

You can also add a leading '?' in the parameter box to see what TC will execute.
Parameters: ?"%P" "%T"
Maybe that will give you a glue?



 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

DelphiDev
Junior Member
Junior Member
Posts: 14
Joined: 2019-03-22, 12:03 UTC

Re: Is there a way to create a custom copy action?

Post by *DelphiDev » 2019-07-05, 12:30 UTC

norfie² wrote:
2019-07-05, 12:16 UTC
2DelphiDev
Did you test my button? (I tested it and it works for me like a charm :D)
There is a problem with admin account and path variable. You need to specify the whole path to xcopy.exe.
Another problem are the backslash signs in the end of the source path and target path. Xcopy don't like that therefore I putted a dot at the end. If you don't like that you could put a file mask mit asteriks *.*
Yes I did and unfortunately it also closes directly. Must have something to do with either my source or target path. The weird thing is that this only happens when I quote %T (which is "c:\Program Files (x86)\MySuperDuperApp\" hence the need to use quotation marks). It works with a target path that does not have a space in its name and thus doesn't need quotes.

@Stefan2 StdOut, yes.

I'd like to pipe StdOut of xcopy to a text file so that I can better analyze the problem.

User avatar
norfie²
Power Member
Power Member
Posts: 838
Joined: 2006-02-10, 07:27 UTC

Re: Is there a way to create a custom copy action?

Post by *norfie² » 2019-07-05, 12:42 UTC

My button works for me with
C:\Program Files (x86)\MySuperDuperApp\
as target path.
Which windows version do you use?

For debugging issue you could use the following button:

Code: Select all

TOTALCMD#BAR#DATA
*%COMSPEC% /c(%SystemRoot%\System32\xcopy.exe
"%P". "%T". /EHKOX || PAUSE)
totalcmd.exe,2
Xcopy with Admin


-1
"War is evil, in so far as it makes more bad people than it takes away."
Immanuel Kant in "Perpetual Peace"

User avatar
petermad
Power Member
Power Member
Posts: 8811
Joined: 2003-02-05, 20:24 UTC
Location: Valsted, Denmark
Contact:

Re: Is there a way to create a custom copy action?

Post by *petermad » 2019-07-08, 13:05 UTC

2DelphiDev
This button works fine for me:

Code: Select all

TOTALCMD#BAR#DATA
*%SystemRoot%\System32\xcopy.exe
"%P". "%T". /HRKYEOX
%COMMANDER_EXE%,2
Xcopy with Admin

1
-1
To make the button:
1. Mark the green text above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctri+C).
3. Right click on TC's buttonbar and choose "Paste".
Please use this method to make the button, to rule out typing errors.

If you don't want subdirs copied - remove the E from /HRKYEOX
If you don't want to copy file ownership - remove the O from/HRKYEOX
If you don't want to copy file audit settings - remove the X from/HRKYEOX

Compared to the others here, I have added R to overwrite read-only files, and Y to not ask for permission to owerwrite. I have also used %COMMANDER_EXE%,2 in stead of totalcmd.exe,2 - this way you wil get an icon on your button in both 32- and 65bit TC
License #524 (1994)
Danish Total Commander Translator
TC 9.5b3 32+64bit on Win XP 32bit, Win 7, 8.1 & 10 (1903) 64bit, 'Everything' 1.4.1.935 (x64)
TC 3.0b12 on Android 6.0
Get: Extended Total Commander Menus | PHSM-Calendar

Post Reply