DexterMorgan Posted May 29, 2008 Share Posted May 29, 2008 Hello, I know how to make my script run at startup but I only want my script to run once at startup. How can i do that. I tried this RegWrite("HKLM\software\microsoft\windows\currentversion\runonce",$scriptname, "REG_SZ", @ScriptFullPath) But it didnt work.. code Link to comment Share on other sites More sharing options...
sandin Posted May 30, 2008 Share Posted May 30, 2008 there is probably more convenient solution, but this is what I've got: $scriptname = StringTrimRight(@ScriptName, 4) $regread = RegRead("HKLM\software\microsoft\windows\currentversion\run",$scriptname) if $regread <> "" Or $regread <> 0 then RegDelete("HKLM\software\microsoft\windows\currentversion\run",$scriptname) #include <GUIConstants.au3> $Form1 = GUICreate("Form1", 439, 80, 193, 125) $Button1 = GUICtrlCreateButton("Run this window on next startup", 24, 24, 393, 33, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 RegWrite("HKLM\software\microsoft\windows\currentversion\run",$scriptname, "REG_SZ", @ScriptFullPath) TrayTip("Run on startup", "THe prog will start at next startup", 10, 1) EndSwitch WEnd Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
crzftx Posted May 30, 2008 Share Posted May 30, 2008 You can't write to HKLM unless run as an admin. Try writing to HKCU instead. Link to comment Share on other sites More sharing options...
Airwolf Posted May 30, 2008 Share Posted May 30, 2008 Hello, I know how to make my script run at startup but I only want my script to run once at startup. How can i do that.I tried thisRegWrite("HKLM\software\microsoft\windows\currentversion\runonce",$scriptname, "REG_SZ", @ScriptFullPath)But it didnt work..If that line of code is in your application without a routine to determine if it has run already, then that would explain your problem. Basically, when your program runs at startup due to the RunOnce key, it is rewriting the registry value to run again at the next startup. You could create a log file or registry key that you can check for to determine if the program has already run. You could also delete the RegWrite() from your script and just create the RunOnce entry manually (or with a .reg file) so the script doesn't add itself back in each time. Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt Link to comment Share on other sites More sharing options...
DexterMorgan Posted May 30, 2008 Author Share Posted May 30, 2008 Thanks Guys for all the help I tried writing to HKCU and it worked. Thank You. code 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