Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

Windows Registry RunOnce Loop

I'm in an environment where apps in the start up menu and Run registry key wont execute anything, but RunOnce will, so I made small script to start the application I want to run on startup then re-write the registry key. However, when I login and teh script runs then exits after firing off my app and re-writing the registry key, windows seems to run it again,

The scenario looks like:

i login -> my script fires and loads notepad -> my script re-writes registry key -> my script exits -> windows runs my script again -> it loads notepad -> my script re-writes registry key -> my script exists -> loop

Is there a way I can achieve this with out the loop?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

probably not without introducing a sleep statement somewhere in your script. the documentation for these keys specifically state to not write back to the key while executing (see http://msdn.microsoft.com/en-us/library/aa376977(VS.85).aspx for details).

you don't mention what version of windows you are running, but if you are running Vista or higher (I believe), you should be able to create a recurring scheduled task to run at user logon.

thanks, mark


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...