3

I have a server access where I want some batch files to run automatically for any user at startup.

The problem is:

  1. Other users are unable to run this file and it is required to be run as the user who created the file (Don't know why?, possibly because they don't have admin privileges)

  2. Even with runas they are prompted for a password. I dont have a problem sharing the password but don't know how the task will be automated.

I tried runas /savecred /user:Username "c:/xyz.bat" but it fails. The command runas works with /netonly but then it prompts for a password.

Is there some way I can get the batch script to run for any user?

4 Answers 4

3

Create a scheduled task, and run it as a given user.

enter image description here

3

If you are running Windows Server or a Professional edition of Windows, you can do this using Group Policy. The scripts will be run as the user who is logging on, whoever that may be, with their respective permissions. They will not be tied to a specific user.

Save your batch scripts in C:\Windows\System32\GroupPolicy\User\Scripts\Logon. Then open Group Policy Editor (gpedit.msc), go to User Configuration > Windows Settings > Scripts (Logon/Logoff), then select Logon on the main panel. Click on Add in the Logon Properties dialog, then Browse to select the script. Repeat this for each script you want to run at logon. For more detailed information, see this Microsoft article.

Adding logon scripts using Group Policy Editor


Note that the above process is for users logging on. If you want scripts to run at system startup with Local System permissions, go to Computer Configuration > Windows Settings > Scripts (Startup/Shutdown) and select Startup, then follow the rest of the procedure above. Scripts for system startup should be stored in C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup.

0

For allowing users to run the file as a different (pre-configured) user, I've had success in the past using Run as SPC, when I had a similar situation. You configure the cryptfile with the intended username and password, and the executable to be run, and it can then be used by anyone without actually giving them access to the account outside of being able to run that specific executable.

0

Windows has a file called Autoexec.bat that allows you to run several commands after a user logs in. As for the permission, it is possible you placed the application on a place locked to ordinary users (assuming it was a NTFS partition), so a solution would be to place the program in the drive's root (say, C:/). Then again, and AFAIK, programs ask for permission when:

  • They are locked in a folder only reachable by administrator users.
  • They mess with the Registry or other parts of the Operating System (at which point the UAC kicks in).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .