DigDeep

Run file at startup

12 posts in this topic

#1 ·  Posted (edited)

Hi,

I have written a code which does too many work. I needed the file to launch at the system login. I have added the Startup entry at the initial of the code as below but when the machine logs in, the file gets enabled only in the Startup but does not runs in the Task automatically.

I have even added this code as a seperate AU3 file giving the same as Startup to call my existing file with all the codes inside and I am adding this new file to Startup but it still does the same action as Above.

 

Could you please let me know why the code does not shows as running in Task Process even though the Startup shows as Enabled?

 

RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Test", "REG_SZ", "Test File Path")
    Run("Test File Path")

 

Edited by sunshinesmile84

Share this post


Link to post
Share on other sites



Just compile to .exe and place in start up folder.

 

Share this post


Link to post
Share on other sites

I did that too but it still doesn't launch at startup.

I am able to run the file manually without issues.it just does't auto start at login which i want.

Share this post


Link to post
Share on other sites

I did that too but it still doesn't launch at startup.

I am able to run the file manually without issues.it just does't auto start at login which i want.

have you compiled as .exe or leaving as .au3?

Share this post


Link to post
Share on other sites

@shaggy89

Yes, I had copied 1st the .exe file, restarted the machine and 2nd created a shortcut in Startup, restarted the machine.

Both ways, I only see the file showing as ENABLED in the Task manager Startup items. But file does not run in Processes.

 

 

Share this post


Link to post
Share on other sites
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Test", "REG_SZ", "Test File Path")     Run("Test File Path")

 

is this the code you wish to run ?

 

try this as a test

run ("cmd.exe")
WinWaitActive("Administrator: C:\WINDOWS\system32\cmd.exe")

as you can see once pc boots up and user has logged in command prompt will open.

if the code your using has to do with registry you may require admin rights.

 

 

Share this post


Link to post
Share on other sites

well, replacing with the CMD as per your's works out here So I would suspect something wrong from my end. Except here is the issue.

I had already added #RequireAdmin at the top of the code. Not sure why it doesn't work if I remove your WinWaitActive line.

Basically, what I needed was to keep the file in the Startup so it runs at login and running the complete script as Loop.

#RequireAdmin

RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Test", "REG_SZ", @DesktopDir & "\ProcessTest.exe")
Run(@DesktopDir & "\ProcessTest.exe")

 

Now, this ProcessTest.exe should always run in Startup and Processes as Loop, so it would keep on checking for the lines I have written in a loop.

#RequireAdmin

While ProcessExists("ProcessTest.exe")
    MsgBox(0, "", "1", 3)
    MsgBox(0, "", "2", 3)
    MsgBox(0, "", "3", 3)
    MsgBox(0, "", "4", 3)
    ContinueLoop
WEnd

 

Share this post


Link to post
Share on other sites

well, replacing with the CMD as per your's works out here So I would suspect something wrong from my end. Except here is the issue.

I had already added #RequireAdmin at the top of the code. Not sure why it doesn't work if I remove your WinWaitActive line.

Basically, what I needed was to keep the file in the Startup so it runs at login and running the complete script as Loop.

#RequireAdmin

RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Run", "Test", "REG_SZ", @DesktopDir & "\ProcessTest.exe")
Run(@DesktopDir & "\ProcessTest.exe")

 

Now, this ProcessTest.exe should always run in Startup and Processes as Loop, so it would keep on checking for the lines I have written in a loop.

#RequireAdmin

While ProcessExists("ProcessTest.exe")
    MsgBox(0, "", "1", 3)
    MsgBox(0, "", "2", 3)
    MsgBox(0, "", "3", 3)
    MsgBox(0, "", "4", 3)
    ContinueLoop
WEnd

 

good making progress. What i want to know is why are you using regwrite?

Use code i sent and compile as .exe then open start menu -> statup (folder) and paste .exe in this folder.

Any .exe in here will be exeicuted once logged in

Share this post


Link to post
Share on other sites

You can't use #RequireAdmin with a start up script because the script is going to wait for you to allow it to run, and it's probably not running in the same session as the user session. Take the #RequireAdmin out and see if it runs.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

@KingBob

Yes #RequireAdmin will not work to startup in Process. Thank you for the suggestion.

@shaggy89

Thank you too. I just used filecopy to get the file in Startup and removed #requireadmin and it is working now.

 

Edited by sunshinesmile84

Share this post


Link to post
Share on other sites

You can't use #RequireAdmin with a start up script because the script is going to wait for you to allow it to run, and it's probably not running in the same session as the user session. Take the #RequireAdmin out and see if it runs.

Interesting. Somewhere else the solution was to link it with a batch file. So I created a "call c:\myEXE\myEXE.exe" batch file and placed THAT in the startup.  Solved the problem and I can retain #RequireAdmin in my EXE. 


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now