How to run python script on windows startup?

.bat file with python E:\pycode\ does nothing but when i run this command manually it works fine, any ideas?

Try using this in the .bat:

call py E:\pycode\

Does that work?

If not you will need to share all of the .bat file for review - its outside of python, but enough people here will be able to review.

It did not help, my batch file - startup.bat, located in shell:startup contains only
call py E:\pycode\

Are you sure your .bat file (not python) is run at all? What you have done to make it running at Windows startup? (I mean things like: specific location on disk or the Windows Registry)

the console opens with the executed command and after time closes

I suspect there may be some errors, but the terminal closes too fast to see them.
Try add pause at the end of your .bat file.

nothing, just empty line, could this be due to the fact that I’m using pyAutoGui?

Possibly. I know next to nothing about pyAutoGui except that it is used to moving mouse and typing.
I think that your script is being run at so early moment at the startup that there is nothing yet on the screen that your script was trying to do.

Could you explain briefly what you script was supposing to do?

run Win + r
type cmd and enter
and type java command to start minecraft server and some other things

Um…I think you don’t need pyAutoGui at all. Try to run the command for java from the Python itself :wink:

it cause error, AccessDeniedException i think same with py auto gui

After a bit of thinking I concluded you may not need Python at all :wink:
If you find a way to run a program in .bat file, then nothing stops you from putting there a command to run the server itself.

solution was very simple, just make task in task scheduler and make it with highest permission

You can do that from script too. Just write:

start /REALTIME java -jar minecraft_server.jar [the rest of parameters]

I hope admins won’t get angry at me for a bit of off-topic :stuck_out_tongue_winking_eye:

Have you looked into other ways to autostart Minecraft?