DigDeep Posted August 30, 2015 Posted August 30, 2015 (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 August 30, 2015 by sunshinesmile84
shaggy89 Posted August 30, 2015 Posted August 30, 2015 Just compile to .exe and place in start up folder.
DigDeep Posted August 30, 2015 Author Posted August 30, 2015 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.
shaggy89 Posted August 30, 2015 Posted August 30, 2015 On 8/30/2015 at 8:54 PM, sunshinesmile84 said: 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?
DigDeep Posted August 31, 2015 Author Posted August 31, 2015 @shaggy89Yes, 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.
shaggy89 Posted August 31, 2015 Posted August 31, 2015 On 8/30/2015 at 8:03 PM, sunshinesmile84 said: 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 testrun ("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.
DigDeep Posted August 31, 2015 Author Posted August 31, 2015 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
shaggy89 Posted August 31, 2015 Posted August 31, 2015 On 8/31/2015 at 11:12 AM, sunshinesmile84 said: 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
BrewManNH Posted August 31, 2015 Posted August 31, 2015 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 GudeHow to ask questions the smart way! Reveal hidden contents 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
DigDeep Posted September 1, 2015 Author Posted September 1, 2015 (edited) @KingBob Yes #RequireAdmin will not work to startup in Process. Thank you for the suggestion.@shaggy89Thank you too. I just used filecopy to get the file in Startup and removed #requireadmin and it is working now. Edited September 1, 2015 by sunshinesmile84
Skysnake Posted September 2, 2015 Posted September 2, 2015 On 8/31/2015 at 3:09 PM, KingBob said: 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?
SJavad766 Posted October 16, 2020 Posted October 16, 2020 I want the program to run on startup without the admin permission again.This script worked in my program, but every time Windows runs, it asks me for admin access.I do not want this message to reappear and allow him access once and for all.
SJavad766 Posted October 16, 2020 Posted October 16, 2020 What should I do if I want the program to run and work on all Windows accounts?
rudi Posted October 26, 2020 Posted October 26, 2020 (edited) Beside the run keys available "in" HKCU as well as HKLM you also can use the Startup folder: #RequireAdmin $lnk=@StartupCommonDir & "\" & StringTrimRight(@ScriptName,4) & ".lnk" if FileExists($lnk) Then MsgBox(0,"Startup Shortcut Check","LNK file already in place") Else FileCreateShortcut(@ScriptFullPath,$lnk) EndIf But if your script needs to run with #RequireAdmin it will come up with a UAC prompt asking for admin creds for common user accounts. Maybe installing as a sevice might be an alternative way to solve your task? Edited October 26, 2020 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE!
caramen Posted October 26, 2020 Posted October 26, 2020 You won't bypass windows security. But if you are admin already with the current user, and you want to disable the UAC "prompt" then you can by writing in the registry. Without #RequireAdmin, so only in this case you can have a prompt activated before the script disable it during the script and enable it back, if wanted after. In the others cases in which you've not the admin rights already with the current user. Then you will be prompt using the #RequireAdmin My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Reveal hidden contents Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now