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?
 
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.
0
 
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%.
0
 
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.
Thanks
0
 
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...
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.