Jump to content



Photo

Command-line runas with password


  • Please log in to reply
14 replies to this topic

#1 Hurmoth

Hurmoth

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 09-March 03
  • Location: Virginia

Posted 08 August 2008 - 19:04

I know it isn't secure, but it is the best thing I have right now, so, here it goes...

I need to be able to run a file as an admin in a batch file (i.e. runas /u:Administrator "%blahblah%.exe").

The runas command built into Windows doesn't support this, but I know I've seen apps that do support this. Anyone know of any that are free?

Remember, the entire thing is command line. Thanks for the help :D


#2 majortom1981

majortom1981

    The crazy one

  • Tech Issues Solved: 1
  • Joined: 30-November 01

Posted 08 August 2008 - 19:10

I know it isn't secure, but it is the best thing I have right now, so, here it goes...

I need to be able to run a file as an admin in a batch file (i.e. runas /u:Administrator "%blahblah%.exe").

The runas command built into Windows doesn't support this, but I know I've seen apps that do support this. Anyone know of any that are free?

Remember, the entire thing is command line. Thanks for the help :D


Hmm I dont have any free utilities. We use the program run as professional here and it does command line and batch file.

#3 OP Hurmoth

Hurmoth

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 09-March 03
  • Location: Virginia

Posted 08 August 2008 - 19:12

Well, it doesn't really have to be free, but $400+ isn't really an option for me.

#4 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 86
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 08 August 2008 - 20:24

Is this what your looking for -- it allows password on the command line

http://www.softtreet.../archive/53.htm

Not sure if its free or not - but you can download from this page, and it seems to run just fine, etc.

edit: Here is some info you might be interested in as well

http://www.commandline.co.uk/sanur/
Free Runas Alternatives

* CPAU Runas alternative supporting encoded passwords.
* LSrunas/LSRunase Console based Runas alternatives, the latter supports encoded passwords.
* AutoIt (v3) Scripting language for automating the Windows GUI.
* SuperExec GUI that encrypts passwords using Windows cryptography API's


BTW the AutoIT would get my vote --- its a tool any admin should have access to.

#5 OP Hurmoth

Hurmoth

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 09-March 03
  • Location: Virginia

Posted 08 August 2008 - 20:41

Thanks BudMan, that's exactly what I'm looking for (Y)

#6 Joel

Joel

    Neowinian Senior

  • Joined: 07-August 01

Posted 10 August 2008 - 00:06

RunasSPC with do this, or you can encrypt the file so that the password is encrypted.

http://www.microsoft...ppowertoys.mspx

#7 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 86
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 10 August 2008 - 12:18

RunasSPC is not a powertoy.. here is the link to that tool

http://www.robotronic.de/runasspc/

#8 XgD

XgD

    Neowinian

  • Joined: 12-May 02

Posted 10 August 2008 - 12:25

runas /savecred will do it if you only need to save one password.

XgD

#9 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 86
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 10 August 2008 - 12:35

^ the problem is that is with /savecred they can run "anything" they want with those credentials.

#10 Joel

Joel

    Neowinian Senior

  • Joined: 07-August 01

Posted 11 August 2008 - 01:34

RunasSPC is not a powertoy.. here is the link to that tool

http://www.robotronic.de/runasspc/

How the heck did my copy/paste not work? :unsure: Thanks for noticing. (Y)

It's a great tool for scripted deploys.

#11 XgD

XgD

    Neowinian

  • Joined: 12-May 02

Posted 11 August 2008 - 13:38

^ the problem is that is with /savecred they can run "anything" they want with those credentials.


But if the other option is to have the password in plaintext in the batch file, this isn't really an issue?

XgD

#12 Joel

Joel

    Neowinian Senior

  • Joined: 07-August 01

Posted 11 August 2008 - 14:19

But if the other option is to have the password in plaintext in the batch file, this isn't really an issue?

XgD

Or use the solution where it isn't. Like mine.

#13 Grogi

Grogi

    Neowinian

  • Joined: 31-July 07
  • Location: Serbia

Posted 11 August 2008 - 18:54

I have positive experience with lsrunas. Bad side: you have exposed password in batch file. Good side: Users doesn't know what is batch file and how to edit it. Also, what they can do with admin pass :D

#14 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 86
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 12 August 2008 - 18:33

But if the other option is to have the password in plaintext in the batch file

But there were many options give than allow you to encode/encrypt the password so that its not plain text, or you could turn the batch into an exe so they can not clearly read the password, etc.

There are other ways to obscure the password in a batch file, /savecred is cut and dry the user can run anything they want without even knowing anything just click use saved credentials.

Off the top a simple method would be to just turn your batch file with the commands in it to a exe. XP comes with the tool IExpress that can do this.

Or you use one of the many free batch to exe converters out there, etc.. etc.

#15 janger

janger

    Neowinian

  • Joined: 23-October 06

Posted 14 August 2008 - 05:23

+Budman's right. AutoIt makes this easy (for XP anyway):
; Are we already admin?
If Not IsAdmin() Then
	RunAsSet($CmdLine[1],'' , $CmdLine[2])
	Run( $CmdLine[3]  )
	Exit
EndIf
Save this script as BatchRunAs.au3 (or whatever) and compile it to an executable with Aut2Exe. Then in the batch file just add the line
BatchRunAs.exe <Username> <Password> Command
If required the username, password and the program to be run can all be hard coded (change the CmdLine[] parameters in the above script), before converting to an exe.