Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

get out of the local admin BOX and start new cmd

Posted on 2004-10-28
21
Medium Priority
?
1,724 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
Comment
Question by:Danny Kon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
21 Comments
 
LVL 30

Expert Comment

by:SteveGTR
ID: 12438575
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:Danny Kon
ID: 12438715
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
ID: 12438760
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:Danny Kon
ID: 12439562
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
ID: 12440793
Sounds like you have it all figured out. What's the problem?
0
 
LVL 6

Author Comment

by:Danny Kon
ID: 12442134
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
ID: 12442687
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
ID: 12443234
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:Danny Kon
ID: 12443546
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
ID: 12444453
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:Danny Kon
ID: 12449155
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:Danny Kon
ID: 12452951
Lets higher the points because of the importancy
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 12453119
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:Danny Kon
ID: 12453707
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
ID: 12455837
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:Danny Kon
ID: 12456226
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
ID: 12456388
Why don't you try it?
0
 
LVL 6

Author Comment

by:Danny Kon
ID: 12457537
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:
SteveGTR earned 2000 total points
ID: 12457575
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:Danny Kon
ID: 12457629
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:Danny Kon
ID: 12472057
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

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to count occurrences of each item in an array.

604 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