Sign in to follow this  
Followers 0
Erik.

Dos command unknow

22 posts in this topic

Hi,

I want to write a simple program for a few dos commands.

How to send a command to dos and get the valeu back in a msgbox?

You do not see the dos box or anything that the user can see that dos is running...

Is there a solution for?

For people that think wrong things.

It is not made for a hack or something, there is a command in dos where you can change all passwords on the computer and for people that do not know how to i would like to make a program...

Hope someone can help me


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

check this out

http://www.autoitscript.com/forum/index.ph...4187&hl=dos

or check the example from the same topic

#include <GUIConstants.au3>
#include <Constants.au3>
#include <process.au3>

$frmLog = GUICreate("Elkie Backup Logger", 474, 285, 193, 115)
$cmdCollect = GUICtrlCreateButton("Do", 385, 20, 81, 41)
$edit1 = GUICtrlCreateEdit("", 22, 21, 354, 243)
GUICtrlSetData(-1, "Resault will be here")
$cmdCancel = GUICtrlCreateButton("Exit", 385, 69, 81, 41)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cmdCollect
            CompileMe()
        Case $cmdCancel
            exit
    EndSwitch
WEnd

Func CompileMe()
    Local $i, $pid, $line = ""
    Local $foo[4]
    $foo[0] = "c:\*.*"

    For $i=0 To 0
        $pid = run(@comspec & " /c dir " & $foo[0] ,"",@SW_SHOW , $STDOUT_CHILD)
        Do
            $line &= StdoutRead($pid)
        Until @error
    Next
    GUICtrlSetData($edit1,$line)
EndFunc
Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

I want to write a simple program for a few dos commands.

How to send a command to dos and get the valeu back in a msgbox?

You do not see the dos box or anything that the user can see that dos is running...

Is there a solution for?

For people that think wrong things.

It is not made for a hack or something, there is a command in dos where you can change all passwords on the computer and for people that do not know how to i would like to make a program...

Hope someone can help me

use this:

#include <Process.au3>
$rc = _RunDos("start Http://www.autoitscript.com")

the command is going to run but im not sure if it's going to show anything to a msgbox

but you can run commands in DOS using this command...

Edited by c4nm7

Share this post


Link to post
Share on other sites

use this:

#include <Process.au3>
$rc = _RunDos("start Http://www.autoitscript.com")

the command is going to run but im not sure if it's going to show anything to a msgbox

but you can run commands in DOS using this command...

I think he wants to write a dos program, not use existing commands

Share this post


Link to post
Share on other sites

I think he wants to write a dos program, not use existing commands

How to send a command to dos

hm i think he wants to use the existing dos commands to a new program, like his own DOS but i will be using msods commands...

this is also,what star2 posted

if he was here he could answer us;;;

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Now i am here :rolleyes:

Ok i don't want tp write a dos program and not my own program for dos:P

What i want to do is send whit auto it the command 'net user'

Then you get alle users of that pc back.

Then whit some other command you can change te password..

Want to write a program that can do it so noobs do not need to ask :rambo:

Zo i need so send something to dos but also get something back...

When u do

#include <Process.au3>

$rc = _RunDos("net user")

msgbox(0,"",$rc)

i only get a 0 back and not other things i need

Edited by Erik.

I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

personally i'd try something along the lines of: (mt syntax may suck, this is to give the idea)

$rc = _RunDos("net user > @TEMPDIR\Output.txt")

then read the file "Output.txt" that DOS will write to in the temp folder instead of the screen & base MsgBox off the content.

don't forget to have the script delete the file afterwards lol

Share this post


Link to post
Share on other sites

$rc = _RunDos("net user > C:\Output.txt")

$get = FileRead("C:\Output.txt")

MsgBox(0,"",$get)

Whit this it works.

Is there a way to do it whitout make a file?


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

You could try reading stdout from the pid returned in $rc it's where most DOS commands write, just i've only just updated to a version that could see it & am therefore not up on how to use it.

Share this post


Link to post
Share on other sites

$rc = _RunDos("net user > C:\Output.txt")

$get = FileRead("C:\Output.txt")

MsgBox(0,"",$get)

Whit this it works.

Is there a way to do it whitout make a file?

A demo using StdOutRead():

#include <constants.au3>

$rc = Run(@ComSpec & " /c net user", @WorkingDir, @SW_HIDE, $STDOUT_CHILD)
$StdOut = ""
While ProcessExists($rc)
    If StdoutRead($rc, 0, 1) Then $StdOut &= StdoutRead($rc)
WEnd
MsgBox(64, "Results", $StdOut)

:rolleyes:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

That works nice :rolleyes:

i made a form etc.. and trying to fix it.

I hope it would be not to hard...

I think the problem would be this:

When u get the usernames you can do this:

net user 'username' *

you need to send this but then you need to send the password 2 times... how could you do that... it must be 1 thing not get the username and close it and then open it and type password...

Edited by Erik.

I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

I am trying but it will be hard i think:P i never use dos in autoit

For example:

#include <constants.au3>

$rc = Run(@ComSpec & " /c net user 'username here' *", @WorkingDir, @SW_HIDE, $STDOUT_CHILD)

When you do that you will get a msgbox back whit the text that you need to enter a password,second password and then that the password was succesfull changed..

Now how to full in the password?

When you do this:

#include <constants.au3>

$rc = Run(@ComSpec & " /c net user 'username here' * password here confirm here", @WorkingDir, @SW_HIDE, $STDOUT_CHILD)

it does not work...

i deleted the script i only need to explain this line..


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

Hmm, I'm not sure if you understand the syntax of the net user command

To add a user called Test, with the password Password, you'd use this:

Run(@ComSpec & " /c net user Test Password /add", @WorkingDir, @SW_HIDE)

Share this post


Link to post
Share on other sites

NET HELP SYNTAX

explains the syntax usage in the help items

and

NET HELP USER

explains the usage of NET USER

in case you wern't already familliar with it

looking at these items myself, it appears you don't need * if you supply the password

* = prompt for it

Share this post


Link to post
Share on other sites

Hi,

To change any password in the pc whit that command you need to type a * after the name and then press enter, it will ask for the new password..

Try it so you can see what i mean..

Press Start, then Run and type cmd

You will get a black box and then type net user

You will get all accounts on the computer

For example: net user administrator *

Then it ask for the new password.

It ask to confirm the password...


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

try playing with StdinWrite

should be able to send the * & the new pass using that, you may have to set a Sleep between

Share this post


Link to post
Share on other sites

Never used but i will try hope it works :rolleyes:


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

To change a password of an existing user with username Test:

net user Test newpass

Works for me, should also work for you.

Edited by FreeFry

Share this post


Link to post
Share on other sites

mmm nice it works:D

i hope it will work for everything...

Thanks


I little problem, hard to find and fix

Share this post


Link to post
Share on other sites

Glad to be of help. :rolleyes:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0