2

There are two batch files. Need to add a condition to the first file if the process is running nvcplui.exe then nothing, and if it is not running, then the second file (or the code from it) will be applied. I am far from programming, so I will be grateful for the finished version.

1 bat

sc config NVDisplay.ContainerLocalSystem start=auto

net start NVDisplay.ContainerLocalSystem

start "" "C:\Program Files\NVIDIA Corporation\NVIDIAControlPanel\nvcplui.exe"

2 bat

net stop NVDisplay.ContainerLocalSystem

sc config NVDisplay.ContainerLocalSystem start= disabled
3
  • Check if is it running or not,use sc query
    – Mr.Key7
    Commented May 25 at 12:11
  • Of the two bat files, I understand file 1 is to start the process, while file 2 is to disable it. So, what is your main goal?
    – Mr.Key7
    Commented May 25 at 12:23
  • To make everything works when running one batch file, Run 1 batch file, the exe start, I work in the application, close the application and 2 batch file were applied. Or that the same thing would work through a single batch file.
    – Agodless
    Commented May 25 at 13:39

1 Answer 1

2

I don't know exactly what you mean.

This is just a script to run and close it. you can choose according to your wishes. (Admin right required).

@Echo Off
:NVidia
CLS 
set #name=NVDisplay.ContainerLocalSystem
sc query | Find.exe /i "%#name%" >Nul && set #Run=y || set #Run=
if defined #Run (
    Echo '%#name%' is Running. Close It^?
) else (
    Echo '%#name%' is Not Running. Start It^?
)
choice /n /m "(Y) Yes (N) Exit:"
if %errorlevel%==2 exit /b
if defined #Run goto :CloseIt

:RunIt
rem sc config NVDisplay.ContainerLocalSystem start=auto
net start NVDisplay.ContainerLocalSystem
start "" "C:\Program Files\NVIDIA Corporation\NVIDIAControlPanel\nvcplui.exe"
goto :NVidia

:CloseIt
net stop NVDisplay.ContainerLocalSystem
rem sc config NVDisplay.ContainerLocalSystem start= disabled
goto :NVidia

if it's just for running and closing, there's no need for sc config. That's its function is to start automatically at startup or deactivate it.
But if you want that, remove rem.
If you want to learn cmd, one easy-to-read reference is SS64


To just run it through the bat, pause, then close.

@Echo Off
rem sc config NVDisplay.ContainerLocalSystem start=auto
net start NVDisplay.ContainerLocalSystem
start "" "C:\Program Files\NVIDIA Corporation\NVIDIAControlPanel\nvcplui.exe"
pause
net stop NVDisplay.ContainerLocalSystem
rem sc config NVDisplay.ContainerLocalSystem start=disabled
4
  • If it's just to run it using bat and close it manually, that's easier. Is that what is meant?
    – Mr.Key7
    Commented May 25 at 15:04
  • Is there a technical possibility not to answer "yes" or "no", that is, without a choice inside the cmd shell. Provided, if we take as initial data, that service NVDisplay.ContainerLocalSystem is disabled by default. By launching the bat file, the service NV Display.Container Local System is enabled and starts nvcplui.exe -pause, then I close it manually nvcplui.exe . -resuming work after that, checking if nvcplui.exe dont run, then NVDisplay.ContainerLocalSystem id shutdown and bat file shutdown to.
    – Agodless
    Commented May 25 at 15:05
  • Sorry for the inaccurate queries, English is not my native language, I write through a translator.
    – Agodless
    Commented May 25 at 15:06
  • Thanks a lot, this option is really almost what I wanted. ``` @Echo Off sc config NVDisplay.ContainerLocalSystem start=auto net start NVDisplay.ContainerLocalSystem start "" "C:\Program Files\NVIDIA Corporation\NVIDIAControlPanel\nvcplui.exe" pause net stop NVDisplay.ContainerLocalSystem sc config NVDisplay.ContainerLocalSystem start=disabled ```
    – Agodless
    Commented May 25 at 15:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .