AlexIII / tcc-g15

Thermal Control Center for Dell G15 - open source alternative to AWCC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autorun on start-up feature

AlexIII opened this issue · comments

The Autorun feature proved to be difficult to implement in windows. The main issue here is to run the program with admin privileges. No doubt the admin-silent-autorun was abused in the past by various malwares, so Microsoft made it difficult to automatically run your app with admin privileges without prompting the user.

I have tried to add the program to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run which solved the autorun part, but it grands no admin rights.

Adding the program to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers with RUNASADMIN value blocks the program start completely (probably, due to the security reasons)...

If anyone has experience on the issue, your input would be very appreciated.

Maybe you can try schtasks command to create a task in Task Scheduler

SCHTASKS /Create [/S system [/U username [/P [password]]]]
[/RU username [/RP password]] /SC schedule [/MO modifier] [/D day]
[/M months] [/I idletime] /TN taskname /TR taskrun [/ST starttime]
[/RI interval] [ {/ET endtime | /DU duration} [/K] ]
[/SD startdate] [/ED enddate] [/IT] [/Z] [/F]

Here is an example:

schtasks/create /tn "TCC_G15" /tr C:\Users\hwc\Desktop\Thermal.Control.Center.v1.4.0.exe /sc ONLOGON /RL HIGHEST

This means creating a task called "TCC_G15", which will run the program with admin privileges when login.

I don't know how to use it in a product, but I have seen some apps in my computer using this to autorun on start-up, maybe you can try it.

Thanks for the hint! I'll make sure to give it a try

@T7imal, does this method work on your system? I've tried to create a task, but it won't run the program on my machine. The task scheduler always reports status "The task has not yet run. (0x41303)"

Yes, it works, and the task scheduler shows "The task is currently running. (0x41301)". Maybe the user you used don't have enough privileges?

Also I find out the how the app I mentioned uses the task scheduler. It has a xml file which contains the needed information, and it will detect its address and write it into the xml file. After that it uses the xml file to create the task.

I exported mine as an example:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2023-06-10T21:33:33</Date>
    <URI>\TCC_G15</URI>
  </RegistrationInfo>
  <Triggers>
    <LogonTrigger>
      <StartBoundary>2023-06-10T21:33:00</StartBoundary>
      <Enabled>true</Enabled>
    </LogonTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>D:\Thermal.Control.Center.v1.4.0.exe</Command>
    </Exec>
  </Actions>
</Task>

And use it with

schtasks /create /xml "the route of the xml file" /tn "TCC_G15"
commented

Hello, I don't know much about programming, but I found that the purpose of booting self-start can be achieved using system settings. The specific method is to enter ‘shell:startup’ after win+R, drag the ‘.exe’ file or shortcut in, and select the object's right-click property to set the running mode to minimized. This not only realizes the automatic startup of the boot, but also does not pop up at startup, so that there is no sense of disturbing.
As I said earlier, I don't know much about programming, and I'm one of the users of the software, hopefully without bothering.

The specific method is to enter ‘shell:startup’ after win+R, drag the ‘.exe’ file or shortcut in, and select the object's right-click property to set the running mode to minimized.

It doesn't work on my system and people say that this method only work for programs that don't require administrator privileges. I wonder why it works on your system.

commented

Sorry for the mistake in my formulation, to be precise, only shortcuts work fine, and '.exe' files do not launch. And there is no minimization option for '.exe' files. If it is not for this reason that it cannot be used, then sorry I don't know the reason for the time being.

Thanks for all your comments, it was very helpful ♡ I will try to return to this feature when I have time, probably this month. The Task Scheduler method seems to work on my machine, but every once in a while the program won't start on a reboot... No idea why and if this is specific to my system only. But I guess at least having that is better than nothing.

Sorry for the mistake in my formulation, to be precise, only shortcuts work fine, and '.exe' files do not launch. And there is no minimization option for '.exe' files. If it is not for this reason that it cannot be used, then sorry I don't know the reason for the time being.

Accidently I have found out the reason why the start-up folder method doesn't work on my system. What I have done is:

  1. Press Win+R, enter "gpedit.msc".
  2. Find "Computer Configuration" - "Windows Settings" - "Security Settings" - "Local Policy" - "Security Options" (Translated. Maybe a little different).
  3. Disable"User Account Control - Run all administrators in administrator mode" (Translated. Maybe a little different).

Then the start-up folder method works.

@T7imal nice catch! Not sure how we can use it though... We cannot possibly start asking users to change their default security settings.