I have a bat file which will delete files in some folder (Profile Folder). But i do-not have access to that folder. But another account has access to the folder. How to run a batch file from one account by login into the another account which has access and delete those files?
Use the runas command.
In Windows Explorer you can right-click on the bat file and choose Run As... then enter your credentials.
You could run it from a scheduled task which lets you set credentials.
You have two options. One means you'll have to manually pass the password each time (not ideal), the other will let you pass with password from the batch file (but this means anyone can read the batch file and discover the password). You choose which flaw you would rather live with:
Option 1 (Manual Password Entry)
Option 2 (Automatic Password Entry)
Use the PsExec command from Microsoft SysInternals PsTools suite:
Please note: The quote marks are in different places for each example. This is intentional. Both commands have have quirks when it comes to passing a command with lots of arguments/switches. The quote marks need to be in the exact locations I've displayed (in relation to command