Sudo like command in dos

Hi,

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.

Thanks


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

Type runas /? for additional switch information.
0
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

cpau.exe

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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

QlemoBatchelor, Developer and EE Topic AdvisorCommented:
As noted, the password is a problem. There are tools like psexec (www.sysinternals.com, 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.
0
DuaneMizellCommented:
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 USAGE:
 
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
                     smartcard.
   /user             <UserName> should be in form USER@DOMAIN or DOMAIN\USER
   program         command line for EXE.  See below for examples
 
Examples:
> runas /noprofile /user:mymachine\administrator cmd
> runas /profile /env /user:mydomain\admin "mmc %windir%\system32\dsa.msc"
> runas /env /user:user@domain.microsoft.com "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

0
xps0Author Commented:
Hi,

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?

Thanks
0
QlemoBatchelor, 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.
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
runas is no solution as it requires at least one interactive login (per interactive user). Not an option here.
0
Monis MontherSystem ArchitectCommented:
you can use cpau.exe its a free tool and you can embed the password within the script
0
QlemoBatchelor, 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.
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
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.