Solved

DOS run a program as another user

Posted on 2007-04-11
9
1,088 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 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