Diana (Cda) Posted April 1, 2009 Share Posted April 1, 2009 Does anyone have have a working example of a Windows startup script that will launch a program, i.e., Notepad (just to give an easy example), the first time on any given day that Windows is launched? I can handle the rest of the script now, it's just how to deal with keeping track of startups. I think an INI file might be used (?) but I'm not sure and, speaking of INIs, haven't broken that barrier successfully as yet. Thanks! <g> Link to comment Share on other sites More sharing options...
Valuater Posted April 1, 2009 Share Posted April 1, 2009 Just put a shortcut in the startup folder.....done! 8) Link to comment Share on other sites More sharing options...
GEOSoft Posted April 1, 2009 Share Posted April 1, 2009 @Val. That won't do what she wants. It will run the app everytime Windows starts not just the first time. Here is a variation on your idea that will do it though. Just Compile the script and Run it once to create the Shortcut and Ini Entry and after that it will only start notepad if it's the first time windows is run that day. $iDate = @Year & @Mon & @MDay ;; If the startup folder link doesn't exist then we create it If NOT IsArray(FileGetShortcut(@StartupDir & "\" & @ScriptName & ".lnk")) Then FileCreateShortCut(@ScriptFullPath, @StartupDir & "\" & @ScriptName & ".lnk") EndIf $ini = @ScriptDir & "\sysrun.ini" $lastrun = IniRead($Ini,"LastStart", "Date", "") ;; If the IniEntry doesn't exist or the date doesn't match then run the startup function, else Exit If (NOT $lastRun) OR ($LastRun <> $iDate) Then _Startup() Func _Startup() ShellExecute("notepad.exe") IniWrite($Ini, "LastStart", "Date", $iDate) EndFunc George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Diana (Cda) Posted April 2, 2009 Author Share Posted April 2, 2009 Hi, GEOSoft! How are you?! <g> I tried out your script immediately but have been testing it. I'm thinking I did something wrong. Here's my modified version, since I really need all the help I can get so tend to make the scripts as re-usable as possible right from the get-go.expandcollapse popup#NoTrayIcon ; AutoIt's icon doesn't show in systray ;========================================================== $appName = "RDbdRem" $appExec = @ScriptDir & "\BIRTHDAY.EXE" ;---------------------------------------------------------- $iDate = @Year & @Mon & @MDay $shortcut = @StartupDir & "\" & @ScriptName & ".lnk" ;========================================================== ;---------------------------------------------------------- ; delete any old LNK, if it exists: If FileExists($shortcut) THEN FileDelete($shortcut) Sleep(150) ;---------------------------------------------------------- ; If the startup folder link doesn't exist then we create it If NOT IsArray(FileGetShortcut(@StartupDir & "\" & @ScriptName & ".lnk")) Then FileCreateShortCut(@ScriptFullPath, $shortcut) EndIf ;---------------------------------------------------------- $ini = @ScriptDir & "\z - " & $appName & "sysrun.ini" ;---------------------------------------------------------- ; delete any old INI, if it exists: If FileExists($ini) THEN FileDelete($ini) Sleep(150) ;---------------------------------------------------------- $lastrun = IniRead($Ini,"LastStart", "Date", "") ;; If the IniEntry doesn't exist or the date doesn't match then run the startup function, else Exit If (NOT $lastRun) OR ($LastRun <> $iDate) Then _Startup() Func _Startup() ShellExecute($appExec) IniWrite($Ini, "LastStart", "Date", $iDate) EndFuncThe good thing is that the script works. The app I use it with, a birthday reminder app, does launch - it's just unfortunate that it launches each and every time Windows is run, which really sort of defeats the whole purpose. So I'm guessing that I did something, somehow, to screw this up. For the life of me, I can't see what I've done. Either than that, or the fact the the ini only has a date on it without anything, might indicate where the problem might lie (?). The INI currently reads like this:[LastStart] Date=20090402I've booted/rebooted a total of 3 times in total today, and the app has launched each and every time. What could be the problem, can you tell? Perhaps it's even something completely different that's causing the problem that I can't see. Anyway, thanks! <g> Link to comment Share on other sites More sharing options...
Developers Jos Posted April 2, 2009 Developers Share Posted April 2, 2009 How could this ever work? If FileExists($ini) Then FileDelete($ini) Sleep(150) ;---------------------------------------------------------- $lastrun = IniRead($ini, "LastStart", "Date", "") 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 More sharing options...
GEOSoft Posted April 2, 2009 Share Posted April 2, 2009 Jos is right. You can't delete that Ini file. It contains the data that determins if the app starts at startup or not. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
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