Sign in to follow this  
Followers 0
AntiVirusGuy

dos commands in autoit help!

11 posts in this topic

#1 ·  Posted (edited)

This is just one of many examples of some dos commands I can not get to run

in dos I used a %1 %2 for the user to enter their username and password now I want to design a gui interface, the interface works fine my commands do not.

Also a dos window flickers up on the screen and then is gone is their any way to see the command it is sending that would tell me what I am doing wrong

here is the command I am trying to send

net use x: \\bigdrive\courseware /USER:domain\username password /persistent:yes

here is my script

$username = "username"

$password = "password"

Run ("net use k: \\bigdrive\courseware /USER:domain\" & $username & " " & $password & " /persistent:yes")

Edited by ssebrownatcolby

Share this post


Link to post
Share on other sites



Run ("net use k: \\bigdrive\courseware /USER:domain\" & $username & " " & $password & " /persistent:yes > errorlog.txt")

That will output any messages from the net command to errorlog.txt. Hope that helps.


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

yeah I thought of that but because the line will not even execute it will not create the log file

Share this post


Link to post
Share on other sites

oh...silly me...remove the () from around the strings for the variables

$username = ("username")
$password = ("password")

to

$username = "username"
$password = "password"

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

If you didn't know, $CMDLine[1] equals the %1 used in DOS...

Read the helpfile for more information on usage.

About that the DOS-window that flickers on your screen,

you can simply just hide it by using @SW_HIDE as the

show-flag for the Run-command.

Check out that the DOS-command that you are trying to run thru

your scripts, are really valid commands and doesn't fail when typing

them normally in a DOS-window... Remember to also check if any

errors occurred. You can do that by checking the @ERROR-macro :

Run(@ComSpec & " /c " & 'net send helge hello!', "", @SW_HIDE)

If @ERROR Then
    MsgBox(16,"Error","Failed !")
    Exit
Else
    MsgBox(64,"Info","Success !")
EndIf

Hope that cleared at least some parts...

Good luck anyway !

-Helge-

Share this post


Link to post
Share on other sites

I just stuck that in the problem is with the " " and the & etc

oh...silly me...remove the () from around the strings for the variables

$username = "username"
$password = "password")

to

$username = "username"
$password = "password"

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

The command works fine in dos there is a problem with my " " and & ets in the "run net use" line any thoughts? thanks for the other info

If you didn't know, $CMDLine[1] equals the %1 used in DOS...

Read the helpfile for more information on usage.

About that the DOS-window that flickers on your screen,

you can simply just hide it by using @SW_HIDE as the

show-flag for the Run-command.

Check out that the DOS-command that you are trying to run thru

your scripts, are really valid commands and doesn't fail when typing

them normally in a DOS-window... Remember to also check if any

errors occurred. You can do that by checking the @ERROR-macro :

Run(@ComSpec & " /c " & 'net send helge hello!', "", @SW_HIDE)

If @ERROR Then
    MsgBox(16,"Error","Failed !")
    Exit
Else
    MsgBox(64,"Info","Success !")
EndIf

Hope that cleared at least some parts...

Good luck anyway !

-Helge-

<{POST_SNAPBACK}>

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

@Helge - the problem was that he can't see the error message made.

I'm running the line through the prompt right now...you aren't typing /USER:domain\ in letter for letter are you, or are you changing that as well?

The only thing I can think of is

RunWait(@Comspec & " /c net use k: \\bigdrive\courseware /USER:domain\" & $username & " " & $password & " /persistent:yes")
Edited by MSLx Fanboy

Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

@Helge - the problem was that he can't see the error message made.

<{POST_SNAPBACK}>

I understood that, but I did say that if he run the DOS-command

'manually' he would easily be able to see the error returned..

And also, while I was still at it, I also gave him some other information

related to his script, which I thought could be useful for him..

If he didn't already know it, that is. I hope that was ok :( :"> :(

Kidding..

Share this post


Link to post
Share on other sites

If you're not certain what your command line looks like, assign it to a variable and show it in a MsgBox before you run it (but don't try to name your variable $cmdline because AutoIt already uses that identifier as Helge pointed out :( ):

$username = "username"
$password = "password"
$commandline = "net use k: \\bigdrive\courseware /USER:domain\" & $username & " " & $password & " /persistent:yes"
MsgBox(0, "Debug", $commandline)
Run ($commandline, @SystemDir, @SW_HIDE)

Also, if you're not working in a production environment and it's permissible to use beta-release software, you could use JPM's beta release build of AutoIt3 which has functions for catching the output of console apps (like NET.EXE). You could use StdoutRead or StderrRead and then test the output to determine success or failure.

Or, since you're using AutoIt, you could use the DriveMapAdd function instead of NET USE (that's what I'd do...)


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

Thank you thank thank you all that help DaveF you got it. with out having the GUICtrlRead function I was mapping with a user name of 9 and password of 10 once I fixed it to use the GUICtrlRead it worked fine. Dave F your debuging technique helped me with that. You guys are the best I have several more bat files I want to convert to a gui interface it should be a snap now

anyone know how to rename a computer in autoit?

$username = GuiCtrlCreateInput("", 50,80,150,20)

$password = GuiCtrlCreateInput("",250, 80, 150 ,20 ,$ES_PASSWORD)

$pwl = GUICtrlRead($password)

$usr = GUICtrlRead($username)

Run ("net use j: \\bigdrive\" & $usr & " /USER:domain\" & $usr & " " & $pwl & " /persistent:yes")

Run ("net use k: \\bigdrive\courseware /USER:domain\" & $usr & " " & $pwl & " /persistent:yes")

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