How do I?

Blitz3D Forums/Blitz3D Programming/How do I?

IPete2(Posted 2005) [#1]
Hiya,

I need one of my programmes to autorun on the startup/booting-up of a Win XP PC - does anyone know how to achieve this please?

Thanks

IPete2.


KuRiX(Posted 2005) [#2]
Yes, use the registry editor functions, look in the code archives, and add that key:

HKEY_LOCALMACHINE\Software\Microsoft\windows\currentversion\run\

here you add your app:

myapp: c:\myapp\myapp.exe

Cheers.


Neochrome(Posted 2005) [#3]
drag a shortcut to the startup on the start menu?


IPete2(Posted 2005) [#4]
Hey KuRiX

thanks man! You are a star! I'll go and look for it now...


I tried tha Neo, it just sat there and looked at me - all sad and quiet. Lol!


IPete2.


IPete2(Posted 2005) [#5]
Does anyone have a copy of the registry functions anywhere please? The link in the code archives is down.

Please help - ta!

IPete2.


Damien Sturdy(Posted 2005) [#6]

HKEY_LOCALMACHINE\Software\Microsoft\currentversion\run\


Shouldn't that be

"HKEY_LOCALMACHINE\Software\Microsoft\Windows\currentversion\run\" Edit: Kurix fixed his post.
?


Also, Creating a SHORTCUT to the program you want to run, in the start menu under "startup" will work- If not, you have issues :P


KuRiX(Posted 2005) [#7]
Yes, cygnus is right, i forgot the windows... hehe. I have edited my post :D

And take care, because you need to be an administrator to access localmachine. If not, try current user.


IPete2(Posted 2005) [#8]
Hey guys,

I managed to get into the regedit and set it all up. But I keep getting a MAV, and its only when it runs as an auto boot - if I double click on the runtime it works just fine.

Any thoughts please would be great!

Ipete2.


John Pickford(Posted 2005) [#9]
It might be something to do with the path.

I find I need something like...

 correctdir=FileType  ("filethatshouldbethere.file")

 if not correctdir then ChangeDir (SystemProperty$ ("AppDir"))



...at the start of my program. If the path isn't set up right this should correct it.


John Blackledge(Posted 2005) [#10]
Pete, I think John Pickford is probably right. You may find you have to use CurrentDir$() then add that to all your loading paths.

I _have_ come across certain (Windowsey) situations that suggest that Windows/Explorer and the Desktop all know what the desired path is, and Explorer effectively does a ChangeDir before running the exe, but that change appears to be local to the Desktop, and not global as us oldtimers were used to.

As I said, when in doubt get/set your own paths, and I _do_ mean absolute, not just relative to the exe.


IPete2(Posted 2005) [#11]
I'll try that tomorrow and report back.

cool thanks guys

IPete2.


John Blackledge(Posted 2005) [#12]
Damn, Pete. I just reread this thread and now I remember that I have had a similar problem to the one you describe:-
you can double-click the shortcut in the Startup folder OK, but it's actually the Auto-run (on the same shortcut!) which causes the problem.

I don't think I ever found a way around this, but at least I can confirm that it's not your imagination.

I can only suggest that you do some pretty extensive inserting of MessageBoxes (BlitzSys dll is great for that) or print to the screen+WaitKey() so that you can get CurrentDir$() at various stages of running, etc and see it as it's happening.


big10p(Posted 2005) [#13]
I just have the following as the first line of code:
  ;ChangeDir SystemProperty("appdir")

which I un-comment when compiling a standalone.


John Pickford(Posted 2005) [#14]
My method copes with both situations so don't need to uncomment anything or change loading paths in the game.


IPete2(Posted 2005) [#15]
I must be doing something else wrong somewhere - it just will not work as an autorun file from boot up!

If I double click on it or it's short cut there is no problem, but trying to make it autorun from boot - it just wont do it - even with the above code in place.


Ah well... Thanks for trying people.

IPete2.


John Blackledge(Posted 2005) [#16]
Can I state the obvious (I don't think you're doing anything wrong, Pete) - I think that the Autorun part of Windows works differently from normal pathing/execing.

Don't you just love Microsoft....

(Personally I think that the MS Exec-er code looks inside the exe, sees that it wasn't compiled using an MS compiler, doesn't use a menu, wants to go full-screen, and it just says 'Screw that!')

Seriously I've noticed that the old 16-bit desktop apps I've written (docking-bar etc) are the last things to be run at bootup; I mean the Desktop's been up for 20 secs before they appear - I guess MS want all their own (hidden) apps and processes well started before they'll take a chance on something so radical as a 16-bit app or a Blitz app.


John Pickford(Posted 2005) [#17]
Did you change the filename to a file that exists in your application folder?


big10p(Posted 2005) [#18]
How will that help? Even if the file doesn't exist, the directory is changed to "AppDir", anyway.


Sledge(Posted 2005) [#19]
Sorry, why do you check for a file JP? You might as well just changedir to the correct directory regardless of whether it's already set or not, surely? It's a win-win situation.

Edit: Great minds...


IPete2(Posted 2005) [#20]
@JP

Yes, I changed it to my prog name plus exe as in:

"ssgb.exe"

Edit:
Doh! I just found out that I should have typed "AppDir" and not hard code the actual directory path myself - oops!

@John et al thanks for trying. My client may not like the situation for now - but until I get this to work how I want it I have no choice, it is installation day. So after today I'll have to do remote testing.

Regard,

IPete2.

PS When I get on site - I'll try and change that bit of JP's code to see if that works on my app now. I shall be back later tonight - hopefully with piccies! :)


John Pickford(Posted 2005) [#21]
Sorry, why do you check for a file JP? You might as well just changedir to the correct directory regardless of whether it's already set or not, surely? It's a win-win situation.


Because when you run your code from the IDE Appdir will be the Blitz dir not your game folder. It's written this way so you can just forget about it rather than having different code depending on how you run it.


Sledge(Posted 2005) [#22]
Ah, I see. But, you know...

If Upper(SystemProperty("appdir"))="C:\PROGRAM FILES\BLITZ3D\BIN\" Then RUNFROMIDE=True


I did unearth something a bit odd, though. I compiled the following code and dragged the resulting exe to the startup folder, creating a shortcut...

Print "Current Dir: "+CurrentDir$()
Print "App Dir    : "+SystemProperty("appdir")
WaitKey


...and both values came out correct (when it auto-ran). Unless different Windows releases operate differently I don't see where the path error can be coming from.