AntiVirusGuy Posted May 15, 2005 Share Posted May 15, 2005 (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 May 15, 2005 by ssebrownatcolby Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 15, 2005 Share Posted May 15, 2005 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()) Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted May 15, 2005 Author Share Posted May 15, 2005 yeah I thought of that but because the line will not even execute it will not create the log file Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 15, 2005 Share Posted May 15, 2005 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()) Link to comment Share on other sites More sharing options...
Helge Posted May 15, 2005 Share Posted May 15, 2005 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 theshow-flag for the Run-command.Check out that the DOS-command that you are trying to run thruyour scripts, are really valid commands and doesn't fail when typingthem normally in a DOS-window... Remember to also check if anyerrors 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 !") EndIfHope that cleared at least some parts...Good luck anyway !-Helge- Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted May 15, 2005 Author Share Posted May 15, 2005 I just stuck that in the problem is with the " " and the & etcoh...silly me...remove the () from around the strings for the variables$username = "username" $password = "password")to$username = "username" $password = "password"<{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted May 15, 2005 Author Share Posted May 15, 2005 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 infoIf 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 theshow-flag for the Run-command.Check out that the DOS-command that you are trying to run thruyour scripts, are really valid commands and doesn't fail when typingthem normally in a DOS-window... Remember to also check if anyerrors 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 !") EndIfHope that cleared at least some parts...Good luck anyway !-Helge-<{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted May 15, 2005 Share Posted May 15, 2005 (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 May 15, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
Helge Posted May 15, 2005 Share Posted May 15, 2005 @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 informationrelated 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.. Link to comment Share on other sites More sharing options...
DaveF Posted May 15, 2005 Share Posted May 15, 2005 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. Link to comment Share on other sites More sharing options...
AntiVirusGuy Posted May 15, 2005 Author Share Posted May 15, 2005 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") Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now