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
LVL 1
bimalprakashsharmaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sirbountyCommented:
Hello bimalprakashsharma,
Not only will you not be able to with runas, you shouldn't.  It would expose your password if you tried this....

~sirbounty
0
sirbountyCommented:
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"

0
bimalprakashsharmaAuthor Commented:
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?
0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

sirbountyCommented:
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
0
Steve KnightIT ConsultancyCommented:
Or if you are running an Active Directory network then run a computer startup script rather than user login script, that runs as the computer which has full file system rights normally.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bimalprakashsharmaAuthor Commented:

I am now running the update as an active directory script. Some computers update while others don't. Why is this?
0
Steve KnightIT ConsultancyCommented:
Try adding some logging.... run something like this as part of the batch file

@echo off
echo %date% %time% START >> \\server\share\logfile-%computername%.txt
\\\server\share\yourprogram.exe >>\\server\share\logfile-%computername%.txt
echo %date% %time% STOPPED >> \\server\share\logfile-%computername%.txt

then look at logfile-computersname.txt for what went on.

Steve
0
bimalprakashsharmaAuthor Commented:

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?
0
Steve KnightIT ConsultancyCommented:
Try adding 2>>\\server\share\logfile-%computername%.txt to the line aswell.  That will capture any error messages too.

Steve
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.