Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorun on start-up feature #7

Closed
AlexIII opened this issue Apr 18, 2023 · 11 comments
Closed

Autorun on start-up feature #7

AlexIII opened this issue Apr 18, 2023 · 11 comments
Labels
help wanted Extra attention is needed

Comments

@AlexIII
Copy link
Owner

AlexIII commented Apr 18, 2023

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.

@AlexIII AlexIII added the help wanted Extra attention is needed label Apr 18, 2023
@T7imal
Copy link

T7imal commented Jun 5, 2023

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.

@AlexIII
Copy link
Owner Author

AlexIII commented Jun 5, 2023

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

@AlexIII
Copy link
Owner Author

AlexIII commented Jun 10, 2023

@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)"

@T7imal
Copy link

T7imal commented Jun 10, 2023

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

@T7imal
Copy link

T7imal commented Jun 10, 2023

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"

@gg958
Copy link

gg958 commented Jul 9, 2023

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.

@T7imal
Copy link

T7imal commented Jul 9, 2023

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.

@gg958
Copy link

gg958 commented Jul 9, 2023

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.

@AlexIII
Copy link
Owner Author

AlexIII commented Jul 9, 2023

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.

@T7imal
Copy link

T7imal commented Sep 9, 2023

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.

@AlexIII
Copy link
Owner Author

AlexIII commented Oct 28, 2023

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

AlexIII added a commit that referenced this issue Oct 28, 2023
@AlexIII AlexIII closed this as completed Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants