Sysinternals Homepage
Forum Home Forum Home > Windows Discussions > Troubleshooting
  New Posts New Posts RSS Feed - command-line runas
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

command-line runas

 Post Reply Post Reply
Author
Message
kaasunaamio View Drop Down
Newbie
Newbie


Joined: 08 August 2007
Location: Finland
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote kaasunaamio Quote  Post ReplyReply Direct Link To This Post Topic: command-line runas
    Posted: 08 August 2007 at 4:18am
(I'm not sure if this is the right place for this kinda trouble but.......)

Hi. I'm having a problem with the runas.exe (command line).
the thing is that I need a batch file which takes 2 registry values, writes them to a reg file and then removes them from the registy, deletes file and quits.
Well, that's no problem, but I need the batch file to use administrator account.. there's your problem Cry

I dont care if the password is in the batch file as plain text.
I absolutely dont want to be prompted for password every time the batch file does something. No, the /savecred doesnt work.
Single file, no third party application. Just bat.

@echo PASSWD| runas /netonly /user:administrator "regedit /s "temp.reg""

I tried the
echo PASSWD| runas /savecred.......... but it's not working.

Batch is working OK if I am an administrator but not with other users.
Problems with parameters too.
Like:
@echo asdf| runas /netonly /user:administrator "echo "Windows Registry Editor Version 5.00 >temp.reg""

What am I doing wrong? The runas doesnt support echo? Well how am I supposed to get the information into reg file then as administrator?
Remember, single bat file. Because that's easy enough to customize on specific computers...

I suppose the problem is all about " 's and |'s and echo's.. or something.
Or maybe this can't be done? Ouch

HeeeLP!




Edited by kaasunaamio - 08 August 2007 at 4:18am
Back to Top
Karlchen View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 June 2005
Location: Germany
Status: Offline
Points: 5131
Post Options Post Options   Thanks (0) Thanks(0)   Quote Karlchen Quote  Post ReplyReply Direct Link To This Post Posted: 08 August 2007 at 2:19pm
Hi, kaasunaamio.

Start here, please, and do what the title asks you to do: Please READ Before POSTING.
The answer to your question should be visible inside the first 10 lines of text (roughly 10).

Karl
Back to Top
kaasunaamio View Drop Down
Newbie
Newbie


Joined: 08 August 2007
Location: Finland
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote kaasunaamio Quote  Post ReplyReply Direct Link To This Post Posted: 09 August 2007 at 12:53am
I read it, and it didn't help me at all (could be that I can't read also). I can't use anything else that already is on the computer(s). This is supposed to be easy-customizable (changing the password), light-weight, one-click maintenance batch. There's no way I can download&install PsTools, mainly because there's too many computers.. Another, command-line solution is what's required here.

And, as I said before, it's NOT the issue of having this done, but having it done as administrator when logged on, for example, as guest.
Can I use the runas only once and then do the stuff and remove administrative rights?

SET PWD=asdf
@echo %PWD%| runas /netonly /user:administrator "echo Windows Registry Editor Version 5.00 >temp.reg"

Error code 87 The parameter is incorrect Wacko

Help. A little help please.
Back to Top
Karlchen View Drop Down
Senior Member
Senior Member
Avatar

Joined: 18 June 2005
Location: Germany
Status: Offline
Points: 5131
Post Options Post Options   Thanks (0) Thanks(0)   Quote Karlchen Quote  Post ReplyReply Direct Link To This Post Posted: 09 August 2007 at 1:45am
Hi, kaasunaamio.

Sorry to learn that you will not be able to use psexec to achieve your goal.
Would have been the most efficient way of doing it.
(Actually, psexec was the 1st thing that came to my mind as the right tool for your task.)

There is no way - that I know of - how you can pipe a password into the runas command.

A minor thing in your commandline: "echo" is an internal command of cmd.exe e.g. So the only way to call "echo" from another application will be to prefix "cmd.exe /c " to the "echo" command.

Sorry, psexec is a very efficient runas replacement. If you cannot use it, then I am afraid I cannot offer you a solution.

--
P.S.:
Quote There's no way I can download&install PsTools, mainly because there's too many computers.
If you are responsible for the administration of a large number of computers, then you should start spending some thoughts on
+ group policies
+ active directory services
They will require a lot of planning, time and effort at the beginning, but will definitely pay-off in the long run.
--

Regards,
Karl


Edited by Karlchen - 09 August 2007 at 2:39am
Back to Top
kaasunaamio View Drop Down
Newbie
Newbie


Joined: 08 August 2007
Location: Finland
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote kaasunaamio Quote  Post ReplyReply Direct Link To This Post Posted: 09 August 2007 at 2:38am
Yes, it seems like this task is impossible because of the limits of the native runas command. I thought I could pipe the password but the it messes up things pretty well.

Like
@echo asdf| runas /env /user:administrator cmd
on guest account actually enters the asdf as admin password, and the new cmd window is running with admin rights. But I cant make it work with regedit /s temp.reg or del temp.reg. It starts up the program but doesn't give admin rights. Not to mention @echo..runas..echo or runas something.exe with command line parameters. Ermm

I'm getting a bad case of headache with this.

Just a little more gooogling & forums browsing about this and I'm ready
to give it up and admit it can't be done without psexec or some other runas.exe.

Thanks for discussing about the problem, Karl. Smile
Back to Top
molotov View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 04 October 2006
Status: Offline
Points: 17516
Post Options Post Options   Thanks (0) Thanks(0)   Quote molotov Quote  Post ReplyReply Direct Link To This Post Posted: 09 August 2007 at 2:29pm
Hi, kaasunaamio.
 
Daily affirmation:
net helpmsg 4006
Back to Top
kaasunaamio View Drop Down
Newbie
Newbie


Joined: 08 August 2007
Location: Finland
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote kaasunaamio Quote  Post ReplyReply Direct Link To This Post Posted: 09 August 2007 at 11:21pm
Smile Thanks for the tip Molotov.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down