Link to home
Start Free TrialLog in
Avatar of jana
janaFlag for United States of America

asked on

How to run a batch file successfully in the user Startup Folder.

We want to have a batch file open when the user logs on every time.  The batch file has a shortcut to it with admin rights and the shortcut is copied at the startp folder (that is "C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup").  Yet, when the PC restart or re-log in, it don't start, all other apps in the startup folder runs, but not the batch file.

Please advice.
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

put the batch file in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
or
use task scheduler to run the batch file on user login with highest privileges
Avatar of jana

ASKER

will try
Avatar of jana

ASKER

Didn't work.  Just doesn't display.

So strange.

I have text files, other apps in the user startup folder not the windows, and all of them start - the batch file doesn't.

What else can it be?
Avatar of jana

ASKER

Placed "paused" statement to see if it passes through this batch file, and nothing; it just goes thru.
Avatar of jana

ASKER

Did noticed that the batch file is not in the Startup folder of Task manager, everything else except the batch file....

please advice
Place the  batch file in particular location and use run registry to that
Avatar of jana

ASKER

What do you mean by "... and use run registry to that"?
ASKER CERTIFIED SOLUTION
Avatar of aravind anche
aravind anche
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jana

ASKER

Understood, will try.
Avatar of jana

ASKER

Thank you!  Just tried it and it works!

Why placing the shortcut in windows startup doesn't work?
you Must be aware that some program needs Administrative privilege to start. Keeping program simply in startup folder doesn't provide the program permission to execute it.

You either need to remove the Option to run program as administrator.
Avatar of jana

ASKER

Yes it has the admin privileges.
Avatar of jana

ASKER

It's ok... u already helped me getting on automatic at every startup.

Thanx
(we'll figure out)
That is not a solution.
Scripts in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run do not run elevated.

Solution: create a scheduled task - David told you and you tried. Of course, it does not display when run with different credentials and elevated - that is normal. But the executable or script does run elevated ("with administrative permissions").
Avatar of jana

ASKER

the shortcut has been elevated with the privileged run as admin, but didn't work.  The registry has been working (would've preferred just placing the shortcut in startup or schedule, but no luck - with batch files - all else do work in startup)
Rayluvs, there is something strange. That registry location does not elevate, sorry, so unless your UAC is off and at the same time The user is administrator, it cannot possibly do system changes elevated.
Avatar of jana

ASKER

Yes the user is admin.
And UAC? Off or on?