Sudo like command in dos


I have a sheel script as follows,
exec /usr/local/bin/sudo -H -u <user> /apps/ame/bin/stclc -4.2

Now I have the same kind of environment on windows.
How can I start stclc process with particular user in dos.


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.

Lee W, MVPTechnology and Business Process AdvisorCommented:
You can't in DOS.

You CAN in a Windows Command Prompt.  (DOS hasn't been used in Windows Since Windows Me died - Is linux without the GUI DOS or is it a command prompt).

You can use the runas command in 2000 and later.

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
Lee W, MVPTechnology and Business Process AdvisorCommented:
runas /u:domainOrMachineName\username "command"

Type runas /? for additional switch information.
Monis MontherSystem ArchitectCommented:
You will have a problem with runas that you cant embed the password for it and script it, you will be prompted for the password (If anyone can solve this please let me know)

An alternative to run dos/windows commands with elevated privleges is to use


This is a 3rd party tool that overcomes this limitation in RunAs (as far as I know)

Note: in all cases you have to put the adminstrator password somewhere,unlike sudo where you use the own users passwords thus no one will have the root password.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
As noted, the password is a problem. There are tools like psexec (, free), which even allow you to start it from another station, but you have to provide the admin passwort again.
To get around the clear password restriction, you can create a service with srvany.exe, give that service the account you need it to run under, and start that service with either net start or sc.exe.
Hello everyone, I use the runas command quite frequently, but one of the options (at least through Windows XP and higher) is the "/SAVECRED" command, which allows the user to save the credentials after typing them in once, right after the first execution of the runas command with the "/SAVECRED" switch.
I have provided the printout for it.

C:\Documents and Settings\dmizell>runas /?
RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
        /user:<UserName> program
RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
        /smartcard [/user:<UserName>] program
   /noprofile        specifies that the user's profile should not be loaded.
                     This causes the application to load more quickly, but
                     can cause some applications to malfunction.
   /profile          specifies that the user's profile should be loaded.
                     This is the default.
   /env              to use current environment instead of user's.
   /netonly          use if the credentials specified are for remote
                     access only.
   /savecred         to use credentials previously saved by the user.
                     This option is not available on Windows XP Home Edition
                     and will be ignored.
   /smartcard        use if the credentials are to be supplied from a
   /user             <UserName> should be in form USER@DOMAIN or DOMAIN\USER
   program         command line for EXE.  See below for examples
> runas /noprofile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
> runas /env / "notepad \"my file.txt\""
NOTE:  Enter user's password only when prompted.
NOTE:  USER@DOMAIN is not compatible with /netonly.
NOTE:  /profile is not compatible with /netonly.
C:\Documents and Settings\dmizell>

Open in new window

xps0Author Commented:

To be more clear on my requirement. One of my java class running on weblogic, is calling a TCL script. from where I have to use this.
exec /usr/local/bin/sudo -H -u <user> /apps/ame/bin/stclc -4.2

Now I have the same kind of environment on windows.
How can I start stclc process with particular user in dos.

Weblogic may receive request from different users across the glob. So Do I require to start dos prompt with "runas" option to start my stclc process. "stclc" runs commands to specific tool.

How does it goes?

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
The TCL script can use psexec with user and password. But you will have to distribute it with your stclc.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
runas is no solution as it requires at least one interactive login (per interactive user). Not an option here.
Monis MontherSystem ArchitectCommented:
you can use cpau.exe its a free tool and you can embed the password within the script
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
CPAU is a good tool if you use it with encoding. But that requires that you always need the same user account for the job.
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

From novice to tech pro — start learning today.