Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

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

Apr
1,822
17
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>

???
 
%_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?
 
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?)
 
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.
 
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.
 
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....
 
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....
 
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 ;-)
 
Back
Top
[FOX] Ultimate Translator
Translate