Solved

DOS run a program as another user

Posted on 2007-04-11
9
1,087 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
regedit.exe REG ADD problems 2 53
how to  skip files that were already there? 3 48
Copy dir and files with robocopy 2 72
Batch Files - Error Handling 4 46
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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