Solved

DOS run a program as another user

Posted on 2007-04-11
9
1,085 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:bimalprakashsharma
  • 3
  • 3
  • 3
9 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18892993
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
 
LVL 67

Expert Comment

by:sirbounty
ID: 18893006
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
 
LVL 1

Author Comment

by:bimalprakashsharma
ID: 18893128
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 67

Expert Comment

by:sirbounty
ID: 18893577
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
 
LVL 43

Accepted Solution

by:
Steve Knight earned 250 total points
ID: 18894040
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
 
LVL 1

Author Comment

by:bimalprakashsharma
ID: 18927967

I am now running the update as an active directory script. Some computers update while others don't. Why is this?
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18928069
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
 
LVL 1

Author Comment

by:bimalprakashsharma
ID: 18928351

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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18930064
Try adding 2>>\\server\share\logfile-%computername%.txt to the line aswell.  That will capture any error messages too.

Steve
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now