Solved BAT File different privileges at lines


Feuer

Fatal Error
Power User
VIP
Local time
9:31 AM
Posts
313
Location
Türkiye
OS
Windows 11 25H2 Home Single Language (26200.8037)
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 My Computer

At a glance

Windows 11 25H2 Home Single Language (26200.8...Intel Core i3-1115G48GBon-board
OS
Windows 11 25H2 Home Single Language (26200.8037)
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
Internet Speed
Slowest internet connection in Europe
Browser
ChromePortable / FirefoxPortable / TorBrowser
Antivirus
G-Virus
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 My Computers

  • At a glance

    Win11 Pro RTM Version 24H2 Build 26100.4202Intel Core i5 11th Gen. 2.40GHz12GB
    OS
    Win11 Pro RTM Version 24H2 Build 26100.4202
    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
  • At a glance

    Win11 Pro RTM Version 24H2 Build 26100.4202Intel Core i5 10th Gen. 2.90GHz16GBOnboard, no VGA, using a DisplayPort-to-VGA a...
    Operating System
    Win11 Pro RTM Version 24H2 Build 26100.4202
    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 My Computer

At a glance

Windows 11Intel Core i5-13400F32 GBNvidia 4060
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 My Computer

At a glance

Windows 7
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 My Computer

At a glance

Windows 11 25H2 Home Single Language (26200.8...Intel Core i3-1115G48GBon-board
OS
Windows 11 25H2 Home Single Language (26200.8037)
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
Internet Speed
Slowest internet connection in Europe
Browser
ChromePortable / FirefoxPortable / TorBrowser
Antivirus
G-Virus
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 My Computer

At a glance

Windows 11 Pro
OS
Windows 11 Pro

Latest Support Threads

Back
Top Bottom