I recently had the same issue and solved it using four files: two .bat files and a shortcut to each.
I wanted a shortcut that a customer could double-click on to update a kiosk from a USB drive/stick.
The first bat file, not running in administrative mode, is launched by a shortcut. That bat file sets an environment variable with the current directory that all four of the files are in (on the USB drive). It then kicks off the second bat file via a shortcut.
The second bat file runs in administrative mode (in the shortcut properties, use the “Advanced..” button to set this) and uses the environment variable set by the first bat file. This second bat file uses robocopy to copy the updated file(s) to the kiosk application folder.
File: Update_the_Kiosk_01.bat:
Setx MYSAVEDDIR %CD%
start "Kiosk Update" /d %MYSAVEDDIR% %MYSAVEDDIR%\Update_the_Kiosk_02.bat-Shortcut.lnk
File: Update_the_Kiosk_02.bat:
robocopy %MYSAVEDDIR%\bin\ C:\KIOSK_APP_DIR\bin\ "myFile_newVersion" /copyall /v /MT
The first shortcut, named “Run_Me_To_Update_Kiosk” has a target of:
%windir%\system32\cmd.exe /k Update_the_Kiosk_01.bat
The second shortcut, named “Update_the_Kiosk_02.bat-Shortcut” has a target of:
%windir%\system32\cmd.exe /k cd /D %MYSAVEDDIR% & Update_the_Kiosk_02.bat
Note that in the first bat file, I needed to specify the link extension “.lnk” even though I can’t see that extension in the filename in a File Explorer window.
Double-click on Run_Me_To_Update_Kiosk to kick it off.
I am sure there is room for improvement, but this worked for me on Windows 10 and Windows 11.