Page 1 of 1 1
Topic Options
#197369 - 2010-01-13 03:29 PM runnas as local admin
Marten Offline
Just in Town

Registered: 2010-01-13
Posts: 1
Loc: WI, USA
I am trying to get runnas to run as local admin. I have tried just /user:administrator, /user:%computername%\administrator and no joy. Any ideas?

Thanks in advance
Mike


Edited by Marten (2010-01-13 03:50 PM)

Top
#197370 - 2010-01-13 04:30 PM Re: runnas as local admin [Re: Marten]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Marten,

Welcome to the board! Man.. It is amazing how these things come up all of the sudden. \:D

Did you get a chance to look over at the FAQ Forum?

Specfically, Installing an Application as an Admin

Well.. Did some research and it is not real simple.. But, as you read my response you will see how to arrive at a good conclusion.. Please bear with me as this response is a little long as I do some pretty extensive testing..

Hmm.. Let's see here.. We can try runas..
quote:


C:\>runas /?
RUNAS USAGE:

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
/user: program

RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]
/smartcard [/user:] 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 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.


Alright, let's try it..
This works.. However, you have to enter in everything manually..
quote:


C:\>runas /profile /env /user:%userdomain%\%username% cmd
Enter the password for DOMAIN\KDyer:
Attempting to start cmd as user "DOMAIN\KDyer" ...

We know with one of the things with the del command, we can echo through a "y" for a response..
For example -
echo y|Del C:\Somefolder\*.*

So, let's take the same logic and try to echo through a password through runas..

This does not work.. That is "echoing" the password through runas..
quote:


echo |runas /profile /env /user:%userdomain%\%username% cmd


C:\>ECHO |runas /profile /env /user:%userdomain%\%username% cmd
Enter the password for DOMAIN\KDyer:
Attempting to start cmd as user "DOMAIN\Kdyer" ...
RUNAS ERROR: Unable to run - cmd
1326: Logon failure: unknown user name or bad password.


This does not work.. Echoing password through runas with a "." as an enter key..
quote:


echo .|runas /profile /env /user:%userdomain%\%username% cmd


This does not work..
quote:


echo |runas /profile /env /user:%COMPUTERNAME%\%username% cmd


This does not work.. Echoing password through runas with a "." as an enter key..
quote:


echo .|runas /profile /env /user:%COMPUTERNAME%\%username% cmd


This does not work..
quote:


runas /noprofile /user:"NT AUTHORITY\SYSTEM" cmd


This does not work..
quote:


echo .|runas /noprofile /user:"NT AUTHORITY\SYSTEM" cmd


Another alternative is SANUR..
http://www.commandline.co.uk/sanur_unsupported/index.html

quote:


Pipe the password 'pa55w0rd' into Runas:-
runas /u:domain\username program.exe | sanur pa55w0rd


This does work!!
quote:


runas /u:%userdomain%\%username% cmd | sanur


Other alternatives..
http://www.commandline.co.uk/sanur/index.html

I tried to find a copy of the Windows 2000 Resource Kit, but could not find it locally..
You are supposed to be able to use the SU.EXE (switch user, which is also used in the UNIX World).. I also think there is a program called SCHTASKS.EXE in the 2000 Resource Kit as well..

Here is another way to schedule tasks..
ftp://ftp.microsoft.com/reskit/win2000/jt.zip


HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#197373 - 2010-01-13 07:32 PM Re: runnas as local admin [Re: Kdyer]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Both ScheduleTask and tcLib UDFs exist here as a wrapper to the rather convoluted JT.EXE syntax.

Creating a scheduled event without a trigger, specifying the command and credentials to use is easy to use and very secure compared to RunNas, RunAs, or SU. The tcLib package can create the task event and then immediately execute it. Get the latest tcLib package, with JT.EXE & full documentation from my web site.

We're working on a package that will push and execute an admin task during login. I'm still looking for 1 user to beta-test the package.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#199095 - 2010-07-23 11:28 PM Re: runnas as local admin [Re: Glenn Barnas]
KIXKicks Offline
Starting to like KiXtart

Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
Beta test requires???
Top
#199098 - 2010-07-24 08:42 PM Re: runnas as local admin [Re: KIXKicks]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
 Originally Posted By: KIXKicks
Beta test requires???
  • A need to run admin tasks during login;
  • Patience and a willingness to work with simple documentation
  • The ability to return detailed feedback - not just for what doesn't work, but for what works well, too.
This project was done for one client and did what we needed, but was never polished to a commercial shine.. If you'd like to give it a try, PM me and I'll wrap it up and put it on our ftp server. Might take a few days to dig it out of the archives and put some notes to it.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#212406 - 2017-04-04 09:36 AM Re: runnas as local admin [Re: Glenn Barnas]
Snickers Offline
Fresh Scripter

Registered: 2017-03-28
Posts: 15
Loc: uk
Hi Glenn,

Can i use a scheduled task to run when a student logs onto a windows terminal server from a linux thin client to run a kix script in elevated status to install a printer?

(From post http://www.kixtart.org/forums/ubbthreads...rue#Post197370)

The script works for me but my account is admin. This is the script that I am testing:

 Code:
;--------Start IF_ELSE.kix--------
If Left(@WKSTA, 1) = "w"
;Delete the printer.
$rc = DelPrinterConnection("PR2-A-E9-17")
;Connect the printer.
$rc = AddPrinterConnection("\\cur-prs\PR2-A-E9-17")
;Set the printer as default.
$rc = SetDefaultPrinter("\\cur-prs\PR2-A-E9-17")
Else
;Do nothing.
EndIf
;-------- end IF_ELSE.kix--------


Edited by Mart (2017-04-04 02:03 PM)
Edit Reason: Please use code tags when posting code.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 687 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.134 seconds in which 0.016 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org