How to? run a BTM in elevated, inv tcc tab window

Apr 2, 2011
1,427
10
54
North Carolina, USA
I have a BTM that copies an INI file to %ProgramFiles% and as such I need to run this BTM in an elevated TCC tab, _only_ if the current session is not elevated. How would I do this please?

start /elevated /inv /tab <path to tcc> /c <path to btm>

???
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,446
88
Albuquerque, NM
prospero.unm.edu
%_ELEVATED tells you whether you're already running elevated. %_CMDSPEC gives you the path to TCC. %_BATCHNAME gives you the full name of the currently running batch file. Am I missing something?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,446
88
Albuquerque, NM
prospero.unm.edu
Ah, I missed the /TAB. I think you'll need to omit that -- I don't believe you can attach an elevated console to a non-elevated Take Command. (But if it's invisible, who cares whether it's entabulated?)
 
Apr 2, 2011
1,427
10
54
North Carolina, USA
Code:
iff %_elevated eq 1 then
  call C:\TCMD\UpdateWinapp2.btm
else
  rem start an elevated TCC invisable to do the copying - mentioned in the iff statement above....
  start /elevated /inv /pgm "%_CMDSPEC" /C "C:\TCMD\UpdateWinapp2.btm"
endiff

should work then?

and C:\TCMD\UpdateWinapp2.btm is:

Code:
  echo.
  copy /md "https://raw.githubusercontent.com/MoscaDotTo/Winapp2/master/Winapp2.ini" C:\TCMD\WinApp2_Ini\
  echo.
  rem convet UNIX to ASCII
  TPIPE /input=C:\TCMD\WinApp2_Ini\Winapp2.ini /eol=0,2,0 /output=C:\TCMD\WinApp2_Ini\Winapp2.MSD
  echo.
  rem copy new winapp2.ini + C:\Users\Galloway\Desktop\Charles Desktop\Annie\custom.ini to %ProgramFiles%\CCleaner\winapp2.ini
  copy "C:\TCMD\WinApp2_Ini\Winapp2.MSD" + "%UserProfile%\Desktop\Charles Desktop\Annie\custom.ini" "%ProgramFiles%\CCleaner\Winapp2.ini"
  echo.
 
Aug 3, 2016
376
9
Netherlands
copy "C:\TCMD\WinApp2_Ini\Winapp2.MSD" + "%UserProfile%\Desktop\Charles Desktop\Annie\custom.ini" "%ProgramFiles%\CCleaner\Winapp2.ini"

When you start a program elevated, %UserProfile% will be the userprofile of admin account, instead of your regular user account.
SET u in the elevated TCC gives me:
Code:
[C:\Temp\ff]set u
USERDOMAIN=FF
USERNAME=Admin
USERPROFILE=C:\Users\Admin

You could use the full path (C:\....) or place the file(s) outside the userprofiel.
 
Apr 2, 2011
1,427
10
54
North Carolina, USA
When you start a program elevated, %UserProfile% will be the userprofile of admin account, instead of your regular user account.
SET u in the elevated TCC gives me:
Code:
[C:\Temp\ff]set u
USERDOMAIN=FF
USERNAME=Admin
USERPROFILE=C:\Users\Admin

You could use the full path (C:\....) or place the file(s) outside the userprofiel.

It works fine as coded....
 
Apr 2, 2011
1,427
10
54
North Carolina, USA
When you start a program elevated, %UserProfile% will be the userprofile of admin account, instead of your regular user account.
SET u in the elevated TCC gives me:
Code:
[C:\Temp\ff]set u
USERDOMAIN=FF
USERNAME=Admin
USERPROFILE=C:\Users\Admin

You could use the full path (C:\....) or place the file(s) outside the userprofiel.

It works fine as coded....
 
Aug 3, 2016
376
9
Netherlands
Charles is correct; you cannot run an elevated tab in a non-elevated TCMD.

What will work (to my surprise, actually) is running as another user in a new tab:
Code:
set password=12345
start "Admin Tab" /TAB /runas admin %password% /pgm tcc.exe
Didn't try to make it hidden, btw.

(Now I have to run to change my password, before I get hacked by forum members ;-)
 
Similar threads
Thread starter Title Forum Replies Date
redwdc btm won't run in ver. 17 but works in ver. 16 Support 11
vefatica Why isn't TCSTART.BTM run? Support 8
C How to? create a JPSoft BTM menu to run custom custom batch files Support 2
K double click to run btm? Support 2
vefatica What limit have I run into? Support 9
S How to? Runs start /w in invisible mode OR run program after exit of another one Support 3
Jay Sage Command Will Not Run Using Short Name of Path Support 5
Peter Murschall BDEBUGGER "Run to Cursor" - where is it ? Support 1
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
D What does the file "..\Everything\Run history.csv" store? Support 5
dcantor How to? Can 32-bit TCC be run on a system with 64-bit TCMD and TCC installed? Support 6
G tcedit ist not run in tc 24 file explorer Support 10
A Windows 10 This app can't run on your PC Support 2
P Run as Admin tab in non-elevated Take Command session? Support 9
Roedy run as administrator Support 27
rps Documentation "Copy+Paste+run" question Support 2
Peter Murschall IDE/BDEBUUGER in TCC 22 didn't run Support 7
fpefpe How to? which will run? Support 1
M How to? Run the control panel from a TCC session... Support 2
M How to? Run TCC from Windows Install DVD... Support 2
B Batch file won't run if there is already an instance of TC 17 running Support 9
P MS VS2013 vsdevcmd.bat fails to run with tcmd 17 x64 Support 10
C How to? run a batch file in administrator mode while debugging in take command software Support 1
Joe Caverly How to? Run DOS .exe's the same way Wine does... Support 3
tmaynard How to? Any way to run a command in a new tab at startup? Support 18
M Installed but can't run Take Command 16.0 Support 5
D Run all .CMD batch files with CMD.EXE Support 16
Joe Caverly Run As Administrator in TCMD16 Support 3
F Sending "Y" to chkdsk to run on C at next reboot Support 25
T tcc /c "[...]" fails when run from third party terminal Support 11
B Select and run lines from Command Input panel? Support 1
Jay Sage Specified INI File Refuses to Run Support 3
A How to? Run a TCC command from external program Support 2
vefatica Coruption after which BTMs won't run Support 7
M How to? Run a command (alias, actually) on a "timed" basis... Support 13
Joe Caverly Copy Paste Run Support 12
S Fixed TCC.EXE 13.03.47 won't run Support 4
Stefano Piccardi run as limited user Support 2
M How to? Windows 7 - run TCC as admin w/o UAC intercept Support 4
E TCC requires elevation to run Support 2
Jay Sage How to Run Non-Elevated From Elevated TCC Support 1
L How can I run tcmd in terminal window only? Support 13
S Run as Administrator question Support 3
Joe Caverly TCMD12 Beta Expired, TCMD11 will not run Support 7
p.f.moore Run as administrator from TCC Support 2
vefatica Help from IDE fails after a non-debug run Support 5
B TCC doesn't run using another user Support 2
A How to Run the 4NT 8.02 .INI Key Version Support 3
D TCC won't run telnet on Windows 7 RC1 Support 5
D Can I use TC to run Cygwin? Support 4

Similar threads