Solved

get out of the local admin BOX and start new cmd

Posted on 2004-10-28
1,721 Views
Last Modified: 2013-11-18
I have no idee about this one so lets start giving 250 points for the answer


Whe have an "DOS" box running in XP but here whe have not enough rights so whe logon as an local admin
with the runas command.
I am looking for a way to exit this local admin without using the runas command because than whe have to use the name of the user
The reason for this is that I am running a batch file and at a certain point this batch file have to get something from the user
settings on the network but logged on as local admin this can not be done.
So I tryed the following  to use "cmd start /b runas /bla /bla" and to put in my batch file "exit" but this didnt work
Has anybody any idee, and again the "runas /user" I cant use or it has to be a general command.
So a solution to open an "normal" cmd from the admin enviremont or to close the admin and to open a new cmd within a batch will be accepted.

Dan
0
Question by:dannykon
    21 Comments
     
    LVL 30

    Expert Comment

    by:SteveGTR
    You can try this:

    runas /user:domain\username "cmd.exe /c yourfullyqualifiedbatchfile.bat"

    The problem is that you'll be prompted for a password. I tried to echo the password to runas like so:

    echo password|runas ...

    But, this results in the following error:

    RUNAS ERROR: Unable to accept input

    0
     
    LVL 6

    Author Comment

    by:dannykon
    Steve,

    The problem is that when the batch is running I have to get out of the admin enviremont
    The batch is running in the start in the normal envirement than it will log on in the same window as the admin the problem is that
    i have to go back to the normal envirement within this batch

    Dan
    0
     
    LVL 30

    Expert Comment

    by:SteveGTR
    I guess your saying that you have to switch users to complete your task. If you could get the runas to work then you could have the batch files wait for the others to complete by checking a shared file.

    For example:

    1) 1st batch file runs and deleted the file c:\temp\_signal_.dat

    2) 1st batch file initiates 2nd batch file run under another account and waits until c:\temp\_signal_.dat exists.

    3) 2nd batch file does what it has to do and then writes to c:\temp\_signal_.dat when finished.

    4) 1st batch file continues.

    You'd check for the file using if exist and you'd wait in between attempts to not tie up resources.
    0
     
    LVL 6

    Author Comment

    by:dannykon
    True but the situation is a bit different.

    1st batch file runs and send some specific user information to a text file
    1st batch file runs and starts an vbscript
    vbcript runs and starts a program
    vbcript runs and starts the admin session
    vbscript is sending keystrokes to the admin session to start a new batch and here is the problem
    2nd batch runs and send information to a text file

    Because I have to start an exe and wait till the window get focus i have to use a VBscript

    Dan
     
    0
     
    LVL 30

    Expert Comment

    by:SteveGTR
    Sounds like you have it all figured out. What's the problem?
    0
     
    LVL 6

    Author Comment

    by:dannykon
    Steve, maybe i am just very unclear read the post above your last post and i go further

    VBscript is sending keystrokes to the admin session and is starting a batch file to extract CACLS information.
    after this information is send to an text file the batch file has to start a program.
    This program requires that I start from a normal cmd session and will not work if i start the program from the admin session.

     please ask me If you need more info

    Dan
    0
     
    LVL 3

    Expert Comment

    by:browolf
    vbscript is notoriously bad at sending keystrokes accurately.  there's a scripting language called Autoit which is much better:
    http://www.hiddensoft.com/AutoIt/
    0
     
    LVL 2

    Expert Comment

    by:Jay-Jay
    No idea, but when using Runas, there is a 3th party utility to pipe a password into the runas command.
    It's named SANUR and can be found here: http://www.commandline.co.uk/sanur/
    0
     
    LVL 6

    Author Comment

    by:dannykon
    Browolf and Jay-Jay.

    My question has nothing to do with sending keystrokes and my question has nothing to do with sending a password to the runas command.
    Because its hard for me to wright English sometimes is the way how I ask a question some kind confusing.

    The initial question is that I start with VBS an admin session this VBS starts in this session a batch file
    now i want to find a way that this batch file gets back to the "normal" envirement

    Dan
    0
     
    LVL 30

    Expert Comment

    by:SteveGTR
    I'm not sure I understand what you are asking. Let me breakdown the processing and you tell me if that is correct and what and where you are having the problem.

    1) You have a DOS box running under the local user's account.

    2) You need admin rights to do something, so you launch another process under the admin account.

    3) The process described in #1 has to wait until the process in #2 finishes.

    I guess my questions are:

    1) Is this correct?

    2) What are the processing in #1 and #3 written with. Is this a batch script or a VB script?

    3) Where do you need our help?
    0
     
    LVL 6

    Author Comment

    by:dannykon
    Steve,

    True the first thing you have to click is an batch

    1> Batch start --> processing and starts a second batch
    2> second batch --> processing and when this batch is finished starts a vb script
    3> VBScripts is opening a program and waits till the program starts
         Same VBScript opens an other execute (here i think i was not clear, this second exe opens the admin box) and this exe sometimes opens in minimal two seconds and sometimes in max 69 seconds so we dont know when it will open.
    thats why i use the vbs because with vbs you can wait till we have focus on the admin box.
    The problem is that I loose control over the first batch.
    The good thing (i hope) is that I can send from this vbs any kind of command to the admin box.
    Everything was ok till I get to the point that whe have to save something to the userprofile on the network.
    Because the user is now the localadmin he dont have the right to map the userprofile settings. eg q: \\mynetwork\user
    When I open a cmd than offcourse I have my  q: \\mynetwork\user.


    1st  Q = correct
    2nd not totaly correct i have to start an exe to open the admin account
    3rd  correct and this is working  

    In total 1vbs and 4 batch

    (user)batch1 --> batch2 --> vbs1 --> exe(local admin) --> batch3 --> batch4

    I need help with wrighting correct what my problem is ;)

    The exe starts the local admin dos box where I start batch3
    batch4 has to get out of this local admin and has to use a normal cmd session

    Again sorry for al the confusion and not descriping correctly my problem

    Dan
       


    1

       
           
    0
     
    LVL 6

    Author Comment

    by:dannykon
    Lets higher the points because of the importancy
    0
     
    LVL 30

    Expert Comment

    by:SteveGTR
    I still can't see why batch4 can't be started by batch1 or batch2. I outlined a method that could be used to signal this processing. The exe or vbs1 script could signal the other batch files.
    0
     
    LVL 6

    Author Comment

    by:dannykon
    Steve Sorry maybe i am just stuppid or I oversee her something

    " I outlined a method that could be used to signal this processing"

    I can not find this method ?
    0
     
    LVL 30

    Expert Comment

    by:SteveGTR
    Something like what I posted above:

    "I guess your saying that you have to switch users to complete your task. If you could get the runas to work then you could have the batch files wait for the others to complete by checking a shared file.

    For example:

    1) 1st batch file runs and deleted the file c:\temp\_signal_.dat

    2) 1st batch file initiates 2nd batch file run under another account and waits until c:\temp\_signal_.dat exists.

    3) 2nd batch file does what it has to do and then writes to c:\temp\_signal_.dat when finished.

    4) 1st batch file continues.

    You'd check for the file using if exist and you'd wait in between attempts to not tie up resources."
    0
     
    LVL 6

    Author Comment

    by:dannykon
    Steve,

    I didnt test this but I think it will not work:
    the problem is that batch1 and the local admin session have the same name
    The VBS is waiting till the local admin session has focus BUT if  batch1 is still running the vbs will focus on batch1

    batch1 = running
    batch2 = running
    vbs1 = running and wait till a CMD (has to be the local admin )session opens (the solution what you give is that the VBS will focus on batch1 so batch3 will run in the session batch1 started)


    Dan
    0
     
    LVL 30

    Expert Comment

    by:SteveGTR
    Why don't you try it?
    0
     
    LVL 6

    Author Comment

    by:dannykon
    I will do you maybe know if there is a way to change the name of a cmd session ?

    Dan
    0
     
    LVL 30

    Accepted Solution

    by:
    I was think the same thing :)

    Use the title command:

    Sets the window title for the command prompt window.

    TITLE [string]

      string       Specifies the title for the command prompt window.
    0
     
    LVL 6

    Author Comment

    by:dannykon
    This is a real new one for me i will try it tomorrow but I think that you again didt it !
    Because I checked it here with the vbs and indeed now i can let the vbs wait on the correct box

    For now thanks but have to check this in the office

    Dan
    0
     
    LVL 6

    Author Comment

    by:dannykon
    Steve,

    Perfect this was the solution for my problem. [grin]
    Program is changing title and will wait till batch3 finish and batch1 will go further.

    Again many thanks great that you stayed on top of the problem.

    Dan
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now