bimalprakashsharma
asked on
DOS run a program as another user
DOS RUNAS feature
I have a .bat file which runs as a user logs in. I want to run a program as another user so I am using the run as feature to do this. RUNAS requires me to enter a password manually. How can I put in the password without any user intervention
I have a .bat file which runs as a user logs in. I want to run a program as another user so I am using the run as feature to do this. RUNAS requires me to enter a password manually. How can I put in the password without any user intervention
What is it you're looking to accomplish - perhaps there's another way...
For example, use schtasks to run local tasks using the System account.
schtasks /create /ru system /sc once /st 09:00:00 /tn TaskName /tr "c:\program.bat"
For example, use schtasks to run local tasks using the System account.
schtasks /create /ru system /sc once /st 09:00:00 /tn TaskName /tr "c:\program.bat"
ASKER
sirbounty:
My users do not have access to a folder in c drive. I want to automatically copy a file in one of the folders which the normal user does not have access to. How can I do this?
My users do not have access to a folder in c drive. I want to automatically copy a file in one of the folders which the normal user does not have access to. How can I do this?
Have a list of computers?
Something like this could work:
for /f %%a in (C:\Computers.txt) do copy c:\sourcefile.txt \\%%a\c$\protectedfolder
Something like this could work:
for /f %%a in (C:\Computers.txt) do copy c:\sourcefile.txt \\%%a\c$\protectedfolder
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am now running the update as an active directory script. Some computers update while others don't. Why is this?
Try adding some logging.... run something like this as part of the batch file
@echo off
echo %date% %time% START >> \\server\share\logfile-%co mputername %.txt
\\\server\share\yourprogra m.exe >>\\server\share\logfile-% computerna me%.txt
echo %date% %time% STOPPED >> \\server\share\logfile-%co mputername %.txt
then look at logfile-computersname.txt for what went on.
Steve
@echo off
echo %date% %time% START >> \\server\share\logfile-%co
\\\server\share\yourprogra
echo %date% %time% STOPPED >> \\server\share\logfile-%co
then look at logfile-computersname.txt for what went on.
Steve
ASKER
I have done the log file method you have suggested and it says "(0) files copied" on the computer that does not work. Why does it work on some and not on others?
Try adding 2>>\\server\share\logfile- %computern ame%.txt to the line aswell. That will capture any error messages too.
Steve
Steve
Not only will you not be able to with runas, you shouldn't. It would expose your password if you tried this....
~sirbounty