dexter Posted December 8, 2009 Share Posted December 8, 2009 Hi ! With your previous help, I went ahead coding the GUI and I am struck at a point now, trying to pass parameters to a command line utility using _runDOS. I have attached the code, please help me out, I get a error at teh _runDOS line. The actual working command of JT in DOS is - JT /snj dial /sc Aijaz "" /ctj startdate=12/22/2009 starttime=02:10 type=once /sj applicationname= C:\windows\connect.bat DontStartIfOnBatteries=0 KillIfGoingOnBatteries=0 SystemRequired=1 DeleteWhenDone=1 /stj disabled=0 JT has to separately downloaded from microsoft and pasted in sys32 directory. It lets you schedule tasks from command line, the advantage being you have access to many features including setting option to wake up to resume tasks. "" is for null password. I suppose Iam making a mistake in passing the parameters to JT from autoit. _RunDOS('JT /snj dial /sc '@UserName' '&$pass&' /ctj startdate='&GUICtrlRead($date)&'starttime='&GUICtrlRead($time)&' type='&$a&' /sj applicationname='@WindowsDir&'\connect.bat DontStartIfOnBatteries=0 KillIfGoingOnBatteries=0 SystemRequired='&$b&' DeleteWhenDone=1 /stj disabled=0') Please guide me. Link to comment Share on other sites More sharing options...
whim Posted December 8, 2009 Share Posted December 8, 2009 Hi dexter In order to reduce the chance of slipups with these long command lines, i always construct them piece by piece. I guess your mistake is in the way you chain your macro's: you need to use '& @blah &' to incorporate these, just like regular $var Also, i find it helps to keep a space before and after '&', for readability. so this is what i got (not tested) $cmdline = 'JT /snj dial /sc ' & @UserName & ' ' & $pass & ' /ctj' $cmdline &= ' startdate=' & GUICtrlRead($date) & ' starttime=' & GUICtrlRead($time) $cmdline &= ' type=' & $a & ' /sj applicationname=' & @WindowsDir & '\connect.bat' $cmdline &= ' DontStartIfOnBatteries=0 KillIfGoingOnBatteries=0 SystemRequired=' & $b $cmdline &= ' DeleteWhenDone=1 /stj disabled=0' _RunDOS($cmdline) ; Note that you can also try one of these, you can ; specify a working dir in this case: Run(@ComSpec & " /c " & $cmdline, "", @SW_HIDE) RunWait(@ComSpec & " /c " & $cmdline, "", @SW_HIDE) HTH, whim Link to comment Share on other sites More sharing options...
dexter Posted December 8, 2009 Author Share Posted December 8, 2009 Hi dexter In order to reduce the chance of slipups with these long command lines, i always construct them piece by piece. I guess your mistake is in the way you chain your macro's: you need to use '& @blah &' to incorporate these, just like regular $var Also, i find it helps to keep a space before and after '&', for readability. so this is what i got (not tested) $cmdline = 'JT /snj dial /sc ' & @UserName & ' ' & $pass & ' /ctj' $cmdline &= ' startdate=' & GUICtrlRead($date) & ' starttime=' & GUICtrlRead($time) $cmdline &= ' type=' & $a & ' /sj applicationname=' & @WindowsDir & '\connect.bat' $cmdline &= ' DontStartIfOnBatteries=0 KillIfGoingOnBatteries=0 SystemRequired=' & $b $cmdline &= ' DeleteWhenDone=1 /stj disabled=0' _RunDOS($cmdline) ; Note that you can also try one of these, you can ; specify a working dir in this case: Run(@ComSpec & " /c " & $cmdline, "", @SW_HIDE) RunWait(@ComSpec & " /c " & $cmdline, "", @SW_HIDE) HTH, whim Thanks a lot Whim, it worked like a charm !! I will take care now on with long statements ... Thanks once again , you made my day !! Link to comment Share on other sites More sharing options...
dexter Posted December 8, 2009 Author Share Posted December 8, 2009 Hi dexter In order to reduce the chance of slipups with these long command lines, i always construct them piece by piece. I guess your mistake is in the way you chain your macro's: you need to use '& @blah &' to incorporate these, just like regular $var Also, i find it helps to keep a space before and after '&', for readability. so this is what i got (not tested) $cmdline = 'JT /snj dial /sc ' & @UserName & ' ' & $pass & ' /ctj' $cmdline &= ' startdate=' & GUICtrlRead($date) & ' starttime=' & GUICtrlRead($time) $cmdline &= ' type=' & $a & ' /sj applicationname=' & @WindowsDir & '\connect.bat' $cmdline &= ' DontStartIfOnBatteries=0 KillIfGoingOnBatteries=0 SystemRequired=' & $b $cmdline &= ' DeleteWhenDone=1 /stj disabled=0' _RunDOS($cmdline) ; Note that you can also try one of these, you can ; specify a working dir in this case: Run(@ComSpec & " /c " & $cmdline, "", @SW_HIDE) RunWait(@ComSpec & " /c " & $cmdline, "", @SW_HIDE) HTH, whim Hey Whim, I m into anotehr issue, earlier I had applicationname=' & @WindowsDir & '\connect.bat' ; but now I am taking path od application from a file drag dropped in a input field. The path has spaces. But when I run the command, it runs, but the path is blank in scheduled task.Any solution on how to manage that ?? $file = GUICtrlCreateInput("",80,210,230,20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $_file = GUICtrlRead($file) $cmdline = 'JT /snj runn /sc ' & @UserName & ' ' & $pass & ' /ctj' $cmdline &= ' startdate=' & GUICtrlRead($date) & 'starttime= ' & GUICtrlRead($time) $cmdline &= ' type=' & $a & ' /sj applicationname='& $_file $cmdline &=' DontStartIfOnBatteries=0 KillIfGoingOnBatteries=0 SystemRequired=' & $b $cmdline &= ' DeleteWhenDone=1 /stj disabled=0' _RunDOS($cmdline) Please reply soon. Link to comment Share on other sites More sharing options...
whim Posted December 8, 2009 Share Posted December 8, 2009 (edited) try this $_file = GUICtrlRead($file) $wrapped = '"' & $_file & '"' $cmdline = 'JT /snj runn /sc ' & @UserName & ' ' & $pass & ' /ctj' $cmdline &= ' startdate=' & GUICtrlRead($date) & 'starttime= ' & GUICtrlRead($time) $cmdline &= ' type=' & $a & ' /sj applicationname='& $wrapped $cmdline &=' DontStartIfOnBatteries=0 KillIfGoingOnBatteries=0 SystemRequired=' & $b $cmdline &= ' DeleteWhenDone=1 /stj disabled=0' _RunDOS($cmdline) whim PS You can stop the 'automatic' quoting when you reply by using the 'Add Reply' button; also, code looks better in posts when you put it between tags: [x] ... your code ... [/x] (replace 'x' with 'autoit') Edited December 8, 2009 by whim Link to comment Share on other sites More sharing options...
dexter Posted December 8, 2009 Author Share Posted December 8, 2009 Hey thanks a lot !! It worked ... !! I got another doubt, as I have said, I am accepting the file to be run using drag drop that gives its full path apart from file name. I am also to make a task close part, that will kill the process using its image name. How can I take out the image name or file name from the full address given by the dropped file?? Thanks in advance Link to comment Share on other sites More sharing options...
whim Posted December 8, 2009 Share Posted December 8, 2009 Look up StringSplit in the help file for more info, but this should do it: $path = "C:\some\path\here\and\an\image.jpg" $temp = StringSplit($path, "\") ; will split the string into an array ; $temp[0] will have the number of elements, so ; $temp[$temp[0]] will be the last element $imgname = $temp[$temp[0]] whim Link to comment Share on other sites More sharing options...
dexter Posted December 9, 2009 Author Share Posted December 9, 2009 Thanks a lot whim ... Thanks to your help that I was able to give my friends the beta version of software on time . Here, suggest me some improvements - Download: http://www.mediafire.com/?jmjjeifimfi Download Code: http://www.mediafire.com/file/emi4co0jwjg/auto connect v2.1 code.rar But you wont be able to run the code until you have JT.exe ( Task scheduler) and Psshutdown(sleep scheduler) in system dir. So, run the installer first, n later go for code. Thanks a lot for your help. I will be back for more Link to comment Share on other sites More sharing options...
dexter Posted December 10, 2009 Author Share Posted December 10, 2009 Hi ! I have another issue. How can I add a hyperlinked label on a window? Please guide me. 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