Solved BAT File different privileges at lines


Feuer

Fatal Error
Member
VIP
Local time
5:24 PM
Posts
168
Location
Türkiye
OS
Windows 11 23H2 Home Single Language
I want to start a bat file with admin priviligies but i want to run some lines without priviligies.
Is it possible?!

Code:
CD /D "%~dp0"

REG IMPORT ".\EXTERNAL\Registry\registry.reg"

TIMEOUT /T 3

call "launcher.exe"

Exit

I want only this line with admin priviligies

REG IMPORT ".\EXTERNAL\Registry\registry.reg"
 

My Computer

System One

  • OS
    Windows 11 23H2 Home Single Language
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO IdeaPad 5 15ITL05
    CPU
    Intel Core i3-1115G4
    Motherboard
    There is no such a God, I only know mother-Earth
    Memory
    8GB
    Graphics Card(s)
    on-board
    Sound Card
    on-board
    Monitor(s) Displays
    (s) is too ambitious for me
    Screen Resolution
    1920*1080
    Hard Drives
    256GB (SSD)
    PSU
    I was very young when I last saw a PSU
    Case
    ...
    Cooling
    My coldness is enough to cool the computer
    Keyboard
    A broken and very clean keyboard
    Mouse
    Rat King
    Internet Speed
    Slowest internet connection in Europe
    Browser
    ChromePortable / TorBrowser
    Antivirus
    Biontech
    Other Info
    I can simply say that I took the red pill and I am not happy with it.
I've never seen it work to "change horses mid-stream", so to speak. You'd probably have to end the .bat file and change to Standard account then restart it as Admin.
 

My Computers

System One System Two

  • OS
    Win11 Pro RTM
    Computer type
    Laptop
    Manufacturer/Model
    Dell Vostro 3400
    CPU
    Intel Core i5 11th Gen. 2.40GHz
    Memory
    12GB
    Hard Drives
    256GB SSD NVMe M.2
  • Operating System
    Windows 11 Pro RTM x64
    Computer type
    PC/Desktop
    Manufacturer/Model
    Dell Vostro 5890
    CPU
    Intel Core i5 10th Gen. 2.90GHz
    Memory
    16GB
    Graphics card(s)
    Onboard, no VGA, using a DisplayPort-to-VGA adapter
    Monitor(s) Displays
    24" Dell
    Hard Drives
    512GB SSD NVMe, 4TB Seagate HDD
    Browser
    Firefox, Edge
    Antivirus
    Windows Defender/Microsoft Security

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom
    CPU
    Intel Core i5-13400F
    Motherboard
    PRIME B760M-A
    Memory
    32 GB
    Graphics Card(s)
    Nvidia 4060
    Sound Card
    On-board
    Monitor(s) Displays
    (2) Acer XD270H B
    Screen Resolution
    1920x1080
    Hard Drives
    (1) M2 1TB
    PSU
    600W
    Case
    Tower
    Cooling
    (3) Case fans
    Keyboard
    Standard
    Mouse
    Standard
    Internet Speed
    250 Mbps
    Browser
    Vivaldi
  • Like
Reactions: OAT
A solution is to run the script as a normal user, but replace the REG IMPORT with an elevated Scheduled Task so it has delegated permissions. The disadvantage is you can't pass an argument for the reg file's pathname, so it must be known by the schtasks /create command.

Run as Administrator:
Code:
schtasks /create /sc ONCE /tn UpdateRegistry /tr "reg import 'path\EXTERNAL\Registry\registry.reg'" /rl HIGHEST /st 00:00 /f

Code:
CD /D "%~dp0"
schtasks /run /rn UpdateRegistry
TIMEOUT /T 3
call "launcher.exe"
Exit 0
 

My Computer

System One

  • OS
    Windows 7
Thanks for the answers dudes.
I figured it out what I want with bat to exe converter.

I created an .exe file that import my reg file with admin privileges.
Batch script works and calls that .exe file without any privileges.
So everything is okay now.
 

My Computer

System One

  • OS
    Windows 11 23H2 Home Single Language
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO IdeaPad 5 15ITL05
    CPU
    Intel Core i3-1115G4
    Motherboard
    There is no such a God, I only know mother-Earth
    Memory
    8GB
    Graphics Card(s)
    on-board
    Sound Card
    on-board
    Monitor(s) Displays
    (s) is too ambitious for me
    Screen Resolution
    1920*1080
    Hard Drives
    256GB (SSD)
    PSU
    I was very young when I last saw a PSU
    Case
    ...
    Cooling
    My coldness is enough to cool the computer
    Keyboard
    A broken and very clean keyboard
    Mouse
    Rat King
    Internet Speed
    Slowest internet connection in Europe
    Browser
    ChromePortable / TorBrowser
    Antivirus
    Biontech
    Other Info
    I can simply say that I took the red pill and I am not happy with it.
^ yep. Only other way I know if is to call a .bat from within a .bat
 

My Computer

System One

  • OS
    Windows 11 Pro

Latest Support Threads

Latest Tutorials

Back
Top Bottom