Jump to content

help on RunOnce at restart of computer


Recommended Posts

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce","AutoInst.au3","REG_SZ",@ScriptFullPath)
    shutdown(2)

Here is my code above. when the computer restarts it gives me "folder with install scripts not found". my entire script first searches if the folder is found or not and if the folder is found it goes ahead with the installation. Everything works well but the moment i use RegWrite above the message that the folder has not been found gets displayed after computer restarts. Where could i be going wrong with my folder path specification on the code above. the AutoInst.au3 is the name of teh main script.

Link to comment
Share on other sites

so you run autoinst.au3 to set the registry key......and that is the same script it calls when you come out of restart?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

so you run autoinst.au3 to set the registry key......and that is the same script it calls when you come out of restart?

definitely yes because the autoinst.au3 actually is the main script that parses more than 20 folders, each folder with its own exe files and the actual autoit installation.

Link to comment
Share on other sites

if the folder is found it goes ahead with the installation.

Maybe in your AutoInst.au3 script you could provide full path instead of the installer name only?

Like from "Run('someinstaller.exe')" to "Run(@ScriptDir & '\someinstaller.exe')"

Link to comment
Share on other sites

Dear friends I hv tried your suggestions but cant seem to figure out how to go on. Please help me. I have finished all the programing of my more than 20 applications together with log files but all I need is a way to use this runonce command after restart and finishes off with the rest of my installations.

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce","Autosetup.au3","REG_SZ",@scriptfullpath)
    shutdown(2)

please can someone help me with how to use the runonce to continue with my script or others after a restart.

Link to comment
Share on other sites

I agree with the above replies regarding seeing the actual code to determine where it's going wrong. But, if not, here's one shot in the dark. Does your "@scriptfullpath" contain any EV's like %SystemRoot% or %ProgramFiles% ? If so you're Registry Key needs to be a REG_EXPAND_SZ instead of the REG_SZ type specified. Again, it would be much easier to know what that key is referencing in the script. Good Luck!

Link to comment
Share on other sites

ok here is my code

$search = FileFindFirstFile("folder with Installations\*")
If $search = -1 Then
    MsgBox(0, "Error", "folder not found!")
    Exit
EndIf

While 1
    $dir = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    runwait("folder with Installations\" & $dir & "\autosetup.au3","folder with installations\" & $dir)
    
WEnd

the above works well without any problem but if i insert this script in the actual autoit installation script

RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce","AutoInst.au3","REG_SZ",@ScriptFullPath)
    shutdown(2)
the computer restarts fine and reads the main calling script but displays folder not found. where am i going wrong with my path specifications. Again the above is the calling script and if my application in the (folder with Installations) needs a restart it goes ahead and uses the "runonce" and it restarts and runs again the calling script which proceeds with other installations. that is what is supposed to do but i still cant figure why its displaying "folder not found" on restart. please help, now I have given u my code as you requested. PLEASE NOTE: the calling script is outside the "folder with installations" folder and it SHOULD REMAIN that way. Edited by goodbyeplanet
Link to comment
Share on other sites

  • Developers

Compile your script and only use the EXE version.... that should solve it.

One thing you also need to take care of is that you use the full path to the exe (or au3) file in the registry as the workdir will not be the scriptdir after a reboot!

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Compile your script and only use the EXE version.... that should solve it.

One thing you also need to take care of is that you use the full path to the exe (or au3) file in the registry as the workdir will not be the scriptdir after a reboot!

I tried your method (au3 to exe) but still I get "folder not found". I also do not think exe or au3 is a problem, at this point I am convinced its my path specifications. I somewhat try to understand your last sentence, do u mean fullpath in my main calling script or in the regWrite? do u mind showing me?.

Link to comment
Share on other sites

  • Developers

Is your script starting and then failing?

If so try setting the workdir by using func FileChangeDir(@ScriptDir) at the beginning of your script to set it correct again.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Is your script starting and then failing?

If so try setting the workdir by using func FileChangeDir(@ScriptDir) at the beginning of your script to set it correct again.

Jos

I have programmed my script to display "folder not found"it says "folder not found" and this is the message i get after a restart. so yes my script definitely starts but it fails. let me try your method and see how it works..
Link to comment
Share on other sites

hallo people I have tried also FileChangeDir(@ScriptDir) but i still get folder not found....please can u help me to find out where i am missing it....everything restarts well and my script gets read but i have failed to understand why i keep getting "folder not found"..please help. this is my final step in the coding i have been doing and sadly it has taken me more than the time I took to code all my entire applications and other scripts..please help.

Link to comment
Share on other sites

  • Developers

hallo people I have tried also FileChangeDir(@ScriptDir) but i still get folder not found....please can u help me to find out where i am missing it....everything restarts well and my script gets read but i have failed to understand why i keep getting "folder not found"..please help. this is my final step in the coding i have been doing and sadly it has taken me more than the time I took to code all my entire applications and other scripts..please help.

You are the only person that can help yourself here....

Add some debugging to a log file to check what the script is doing and why it is giving this error.

Again, the only difference I can think of is that when you run the script initially the WorkDir will be the Scriptdir and when it starts at Startup it will be a totally different directory.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

auch!! that hurts

Its not intended that way..

I cannot help when you do not post a script that shows the problem and possibly give an option to test.

Always been a looser when it comes to guessing ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

here is my code below. The script works well without any problem but the problem comes if I restart pc after having used RegWrite. I get an error that "folder not found". Jos told mee that probably its a problem that is happening at startup a but i cant seem to figure how i can do it..I looked deep into files and search and paths this afternoon but i cant seem to solve this problem.

$search = FileFindFirstFile("folder with Installations\*")
If $search = -1 Then
    MsgBox(0, "Error", "folder not found!")
    Exit
EndIf

While 1
    $dir = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    runwait("folder with Installations\" & $dir & "\autosetup.au3","folder with installations\" & $dir)
    
WEnd
Edited by goodbyeplanet
Link to comment
Share on other sites

  • Developers

here is my code below. The script works well without any problem but the problem comes if I restart pc after having used RegWrite. I get an error that "folder not found". Jos told mee that probably its a problem that is happening at startup a but i cant seem to figure how i can do it..I looked deep into files and search and paths this afternoon but i cant seem to solve this problem.

$search = FileFindFirstFile("folder with Installations\*")
If $search = -1 Then
    MsgBox(0, "Error", "folder not found!")
    Exit
EndIf

While 1
    $dir = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    runwait("folder with Installations\" & $dir & "\autosetup.au3","folder with installations\" & $dir)
    
WEnd

Why create a new topic? this is the 3rd thread you start for this script...

Did you do any debugging yourself yet to establish the workdir / current dir both at manual start and boottime?

Again: Post a "real" script we can look at or at least do some debugging yourself first.

EDIT: Merged the topics to keep the info together.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Why create a new topic? this is the 3rd thread you start for this script...

Did you do any debugging yourself yet to establish the workdir / current dir both at manual start and boottime?

Again: Post a "real" script we can look at or at least do some debugging yourself first.

EDIT: Merged the topics to keep the info together.

sorry for breaking the rules Jos, i didnt mean to disrupt the forum or cause some chaos, I was trying to rephrase since I had no answers. yesterday many people asked me to post my real code and today I did so. Now u ask me to post the real code. I dont know what u mean by real code since the code i have posted is my code that i learnt from the help file. Theother other code that I have not posted is my actual installation code but then how important is my installation code since all it has is nothing but a series of winwaitactive, etc and then completes the execution by using the Regwrite statement and then restarts the pc and then invokes the main calling script (which I have posted) and then installation of other applications in other folders continue... If you want me to post my entire code then you might need to know that I have more than 20 application installation scripts and the code I have posted actually calls the installation folder with folders that contain applications and parses all the folders and completes the installation. so what exactly do u mean by posting the real code.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...