I was using Rebex Tiny SFTP Server for some simple file transfer but that program locks its “data” folder inside the exe folder as its shared root. Using symlink, I can manipulate the real folder I’m sharing (tested), not having the trouble of really copying/moving files everytime I change my mind.
For even more convenience, I thought of using right click with batch file to further automate the process.
Wrote a bat:
rmdir/s "...Rebex Tiny SFTP Server 1.0.21data"
mklink /d "...Rebex Tiny SFTP Server 1.0.21data" %1
Then add to context menu with Command:
"...Set SFPT Root.bat" "%V"
Successful but Needs Admin Previledges
Methods I Tried:
-
using
nircmd elevate "...Set SFPT Root.bat" "%V"in the context command. And just a flash of cmd prompt. No results. I even added pause in the end of my bat. Still can’t see what’s going on. -
Added the elevation script copied from another stack post to my bat
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%SysWOW64cacls.exe" "%SYSTEMROOT%SysWOW64configsystem"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%system32cacls.exe" "%SYSTEMROOT%system32configsystem"
)
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%getadmin.vbs"
set params= %*
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%getadmin.vbs"
"%temp%getadmin.vbs"
del "%temp%getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
:: Main Script Starts
But it seems the added script messes up the variables and the path of the selected folder by the right click is gone. How can I achieve my goal?