Startup exe Fails

Dear all,
I wrote a code using python than consists of a couple of processes popens some FTPs and works fine!
I used pyinstaller --onefile --noconsole and created an exe file which still works as planned.
My goal is to add it to the windows startup 7, 8.1 and 10 and I should do it in 250 laptops at work.
I put it in %TEMP% folder and still works on click!
The problem is when I add it to "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" it gives me an error that the script fails!!!!
but when I add it to the start menu's startup it works fine! have anyone noticed the problem!!!
It is driving me crazy
Note 1: I tried other directories
Note 2: I tried run as admin
Shahab GhosniNetwork Infrastructure EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dr. KlahnPrincipal Software EngineerCommented:
When it runs out of the Registry, it may be missing context such as default paths (and probably Administrator privileges too, but that is another issue).  The default paths don't exist until a user logs in and if the script is running before the default paths are defined, the results are unknown.  I'd check that first, specifically by having it print %PATH%, %COMSPEC% and %PATHEXT%.
Shahab GhosniNetwork Infrastructure EngineerAuthor Commented:
Dear Dr.Klahn,
That's a good point and I expected it before so I added a 30 seconds sleep time before the main code gets executed! and the funny thing is for that 30 seconds I can see it's process running in the task manager and after that the error occurs.
I'll recompile a file that prints out the paths to a file just to make sure.
Shahab GhosniNetwork Infrastructure EngineerAuthor Commented:
I did the trick! the funny part is it wont even open up a text file to store log and now the error occurs before the sleep time (the log should open a file before the sleep time) so I guess this is a permission issue! doesn't the registry startup item use the current user's permission level? as this is obvious that the user can run the exe without a problem. I even used the --uac-admin with the pyinstaller but still no luck!!!!
please somebody help...
Dr. KlahnPrincipal Software EngineerCommented:
doesn't the registry startup item use the current user's permission level?

Not if the process starts before the user logs in.  There is no user context in that case.  It is my understanding that processes run out of the Registry (unlike processes run out of the Startup group) run before the user logs in.  That being the case it doesn't make any difference how long they wait; they will still have no user context.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shahab GhosniNetwork Infrastructure EngineerAuthor Commented:
I did 2 things, First I changed the working directory second I realized each shell command needs some sleep time to complete...
Thanks for the help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.