Vikiller94
Vikiller94

Reputation: 11

Convert Batch file to Exe with administrator privileges

I have created a code in , which works perfectly only when I run it as . If not, some of the main functions of the code does not work. On top of that, I would like to convert it to , so that I can put an icon on.

Can anyone tell me please, how can I convert a file to with privileges? If it is possible without prompt?

By the way: I am on my PC.

I have tried with some software:

  1. Iexpress -> Temp-file was not found.
  2. Bat to Exe Converter -> After starting the .exe file it does not run as administrator, although I run it as.

That's the code:

@echo off
start "" "C:\Users\Viktor\Documents\FreeFileSync Auftraege\RealTimeSync Auftraege\RealTime_(.minecraft-GoogleDrive)_[Mirror].ffs_real"
start "" "C:\Users\Viktor\Documents\FreeFileSync Auftraege\RealTimeSync Auftraege\RealTime_(.minecraft-Backupfolder)_[Mirror].ffs_real"
start "" "C:\Program Files (x86)\Minecraft\MinecraftLauncher.exe"

:Anfang
tasklist /v | find "MinecraftLauncher.exe"
if %errorlevel% == 1 goto Dead

tasklist /FI "IMAGENAME eq javaw.exe" 2>NUL | find /I /N "javaw.exe">NUL
if %errorlevel% == 0  goto Active
goto Anfang

:Active
tasklist /v | find "javaw.exe"
if %errorlevel% == 1 goto Dead
goto Active

:Dead
timeout 5
taskkill /F /IM "RealTimeSync_x64.exe"
exit

It works only with "run as administrator". Without, some functions like taskkill or tasklist does not work.

Upvotes: 1

Views: 3286

Answers (2)

PryroTech
PryroTech

Reputation: 504

Here is how you can make your .bat to .exe file require administrator privileges to run:

  1. Download Bat To Exe Converter from Softpedia.com: https://www.softpedia.com/get/System/File-Management/Batch-To-Exe-Converter.shtml (Version 3.2 seems to be a good option due to it's easy layout/interface.)
  2. Once downloaded, go through the install the application and run said application.
  3. Input code into the IDE window, ensuring that you check the box (under the options tab) that says "Request Administrator Privileges"
  4. Now click convert, and continue through the prompts and you will have your .exe file ready for use!

enter image description here

Upvotes: 1

djibe
djibe

Reputation: 3038

I succeeded with Bat to Exe Converter available here : https://www.majorgeeks.com/files/details/bat_to_exe_converter.html Simple GUI to transform batch to exe with administrator privileges.

Upvotes: 1

Related Questions