MikeS Posted December 29, 2006 Share Posted December 29, 2006 Hello, I like to know how I can write a GUI that can update with parameters that can write to a cmd file. (Login.cmd ) Example: Net use \\192.168.1.111\ipc$ /user:192.168.1.111\Username Password I would like to have a utilty that can write three parameters into this cmd file. Using a simple Autoit GUI 1) ipaddress 2) username 3) password So if I can have three text boxes to input these parameters, the Autoit GUI can then input this into the login.cmd file. What I 'm trying to do is have the user use the GUI, instead of editing my login.cmd file. Thanks, for your help Mike Link to comment Share on other sites More sharing options...
JSThePatriot Posted December 29, 2006 Share Posted December 29, 2006 Hello, I like to know how I can write a GUI that can update with parameters that can write to a cmd file. (Login.cmd )Example: Net use \\192.168.1.111\ipc$ /user:192.168.1.111\Username Password I would like to have a utilty that can write three parameters into this cmd file. Using a simple Autoit GUI1) ipaddress 2) username 3) password So if I can have three text boxes to input these parameters, the Autoit GUI can then input this into the login.cmd file. What I 'm trying to do is have the user use the GUI, instead of editing my login.cmd file. Thanks, for your help MikeMike, I hope you aren't expecting someone to write this out for you. There are several functions that I feel you should look at to accomplish what you are wanting to do.FileWrite, FileWriteLine, InputBoxYou actually wouldn't need to create a full fledged GUI if you use the above function list, and compare it to the help file to figure out what each function does, and how it will help you.Mike, I would also like to recommend a tutorial that will help you get started in a scripting environment.Welcome to AutoIt 1-2-3If you post some code then people will be more willing to help you debug it. It seems though you are expecting us to spend our valuable time that we are donating to help to write your entire script for you.I hope I have been of some assistance,JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
MikeS Posted December 29, 2006 Author Share Posted December 29, 2006 (edited) Mike, I hope you aren't expecting someone to write this out for you. There are several functions that I feel you should look at to accomplish what you are wanting to do. FileWrite, FileWriteLine, InputBox You actually wouldn't need to create a full fledged GUI if you use the above function list, and compare it to the help file to figure out what each function does, and how it will help you. Mike, I would also like to recommend a tutorial that will help you get started in a scripting environment. Welcome to AutoIt 1-2-3 If you post some code then people will be more willing to help you debug it. It seems though you are expecting us to spend our valuable time that we are donating to help to write your entire script for you. I hope I have been of some assistance, JS Here is what I have so far, but still need help linking the variables to the inputbox, then to the file. expandcollapse popup ;Autoit Script v1.0 ;Writes to Login.cmd file, with user input dialog ;----- DEFINE ALL VARIABLES AND CLEAR CURRENT VALUES Dim $username Dim $password Dim $ipaddress $username = "" $password = "" $ipaddress = "" ;Places the input box in the top left corner displaying the characters as they ;are typed. $username = InputBox("Login Information", "Enter your username.", "", "") ;Asks the user to enter a password. Don't forget to validate it! $passwd = InputBox("Security Check", "Enter your password.", "", "*") ;Asks the user to enter a 1 or 2 character response. The M in the password ;field indicates that blank string are not accepted and the 2 indicates that the ;responce will be at most 2 characters long. $ipaddress = InputBox("Workstation Information", "Enter the IP Address of Workstation.", "", "") ;Text that I need to get writen to push.cmd file ;username is Mike Smith ;password is 12345678 ;IP address is 10.16.115.124 ; ;Net use \\10.16.115.124\ipc$ /user:10.16.115.124\Mike Smith 12345678 ; $file = FileOpen("c:\push.cmd", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, "Line1") FileWrite($file, "Still Line1" & @CRLF) FileWrite($file, "Line2") FileClose($file) This is what I did to the push.cmd file. Net use \\$ipaddress\ipc$ /user:10.16.115.124\MIke Smith 12345678 Result is this: $ipaddressStill Line1 Line2 So if I can get help with linking these together is will help me, learn the processes. Thanks, Mike Edited December 29, 2006 by MikeS Link to comment Share on other sites More sharing options... MikeS Posted December 29, 2006 MikeS Members 19 Author Share Posted December 29, 2006 I also tried this, with no luck? $file = FileOpen("c:\push.cmd", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $FindText = "@ipaddress" $ReplaceText = "cat" $FileContents = FileRead("push.cmd") $FileContents = StringReplace($FileContents,$FindText,$ReplaceText) ;FileWrite($file, "ipaddress") ;FileWrite($file, "Still Line1" & @CRLF) ;FileWrite($file, "Line2") FileClose($file) Link to comment Share on other sites More sharing options... MikeS Posted December 29, 2006 MikeS Members 19 Author Share Posted December 29, 2006 Found this, but having trouble converting it to work with my project. It seems hard to me, but I'm replacing an ip address, which is always different, so how can I adopt this sample code into my project. It seems just what I need. $oIE = _IECreate() _IENavigate($oIE, "http://www.autoitscript.com/") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "automation") Then MsgBox(0, "Success", "The string was found") $newbody = StringReplace($body, "automation", "AUTOMATION - Yeah!") _IEBodyWriteHTML($oIE, $newbody) Else MsgBox(0, "Fail", "The string was NOT found") EndIf Exit Thanks, for your help. Mike Link to comment Share on other sites More sharing options... James Posted December 29, 2006 James MVPs 10.2k Share Posted December 29, 2006 Thats for Automating IE functions. If your using your script for CMD, I don't think it will do it for you. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options... MikeS Posted December 29, 2006 MikeS Members 19 Author Share Posted December 29, 2006 Thanks for the information. So do you know which one of these functions will work for me. Mike Link to comment Share on other sites More sharing options... Zedna Posted December 29, 2006 Zedna MVPs 9.9k 32 AutoIt rulez! Share Posted December 29, 2006 Thanks for the information. So do you know which one of these functions will work for me. Mike ;Autoit Script v1.0 ;Writes to Login.cmd file, with user input dialog ;----- DEFINE ALL VARIABLES AND CLEAR CURRENT VALUES Dim $username Dim $password Dim $ipaddress $username = "" $password = "" $ipaddress = "" ;Places the input box in the top left corner displaying the characters as they ;are typed. $username = InputBox("Login Information", "Enter your username.", "", "") ;Asks the user to enter a password. Don't forget to validate it! $passwd = InputBox("Security Check", "Enter your password.", "", "*") ;Asks the user to enter a 1 or 2 character response. The M in the password ;field indicates that blank string are not accepted and the 2 indicates that the ;responce will be at most 2 characters long. $ipaddress = InputBox("Workstation Information", "Enter the IP Address of Workstation.", "", "") ;Text that I need to get writen to push.cmd file ;username is Mike Smith ;password is 12345678 ;IP address is 10.16.115.124 ; ;Net use \\10.16.115.124\ipc$ /user:10.16.115.124\Mike Smith 12345678 $text = @CRLF & 'Net use \\' & $ipaddress & '\ipc$ /user:' & $ipaddress & '\' & $username & ' ' & $passwd & @CRLF $file = FileOpen("c:\push.cmd", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, $text) FileClose($file) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
MikeS Posted December 29, 2006 Author Share Posted December 29, 2006 (edited) expandcollapse popup;Autoit Script v1.0 ;Writes to Login.cmd file, with user input dialog ;----- DEFINE ALL VARIABLES AND CLEAR CURRENT VALUES Dim $username Dim $password Dim $ipaddress $username = "" $password = "" $ipaddress = "" ;Places the input box in the top left corner displaying the characters as they ;are typed. $username = InputBox("Login Information", "Enter your username.", "", "") ;Asks the user to enter a password. Don't forget to validate it! $passwd = InputBox("Security Check", "Enter your password.", "", "*") ;Asks the user to enter a 1 or 2 character response. The M in the password ;field indicates that blank string are not accepted and the 2 indicates that the ;responce will be at most 2 characters long. $ipaddress = InputBox("Workstation Information", "Enter the IP Address of Workstation.", "", "") ;Text that I need to get writen to push.cmd file ;username is Mike Smith ;password is 12345678 ;IP address is 10.16.115.124 ; ;Net use \\10.16.115.124\ipc$ /user:10.16.115.124\Mike Smith 12345678 $text = @CRLF & 'Net use \\' & $ipaddress & '\ipc$ /user:' & $ipaddress & '\' & $username & ' ' & $passwd & @CRLF $file = FileOpen("c:\push.cmd", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, $text) FileClose($file) Thanks for all of your help. I do have one other question, with this code. I need to write to the push.cmd file, but I need to not append lines to it, I need to update the parameters already in place within the file. So everytime I reference username, i'd use $username, so is that the right Autoit Function FileWrite Like this: CD C:\FastPush\vnc7 Net use \\@ipaddress\ipc$ /user:10.16.115.124\Mike Smith 12345678 call "C:\\FastPush\vnc7\vnc7.noicons.cmd" 10.16.115.124 /ULTRA /noshortcut mkdir \\10.16.115.124\c$\temp Change to: CD C:\FastPush\vnc7 Net use \\@ipaddress\ipc$ /user:@ipaddress\$username $password call "C:\\FastPush\vnc7\vnc7.noicons.cmd" @ipaddress/ULTRA /noshortcut mkdir \\@ipaddress\c$\temp I hope you can understand what I'm trying to do, if not please post, and I'll try to answer your questions. It seems like I need to replace, to be able to replace file text properties? Thanks, again Mike Edited December 29, 2006 by MikeS Link to comment Share on other sites More sharing options...
Zedna Posted December 29, 2006 Share Posted December 29, 2006 (edited) $file_name = 'c:\login.cmd' $text = FileRead($file_name) $text = StringReplace($text, '10.16.115.124', $ipaddress) $text = StringReplace($text, 'Mike Smith', $username) $text = StringReplace($text, '12345678', $password) FileDelete($file_name) FileWrite($file_name, $text) Edited December 29, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
MikeS Posted December 29, 2006 Author Share Posted December 29, 2006 Hi, Zedna Where do I place this code? Also I see the variables Mike Smith, but these will change everytime this script is ran. What my plan is to have Autoit display Input Boxes, that the user will input username, password and ipaddress of machine he or she is trying to connect to. I Autoit will then write this information for the input box to the push.cmd file. So I thought I would set the variables inside the push.cmd file before using the file. So how can I get this implemented using this code? Thanks, MIke Link to comment Share on other sites More sharing options...
Zedna Posted December 29, 2006 Share Posted December 29, 2006 I gave you only ideas how to achieve some functionality in AutoIt. You must learn something from the HelpFile and improve this base code for your needs. If you encounter some AutoIt problem post it here we will see... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
MikeS Posted December 29, 2006 Author Share Posted December 29, 2006 How can I set a varable for an username, password, or ip address. When they will always be different? I guess this is were I need help. because once I figure that out I can you the StringReplace to replace the variable with the input box parameters. I have seen now how you can use the FileWrite to replace text you already know. I have look into the help files and tutorials too. Thanks, Mike Link to comment Share on other sites More sharing options...
Zedna Posted December 29, 2006 Share Posted December 29, 2006 Const $template = _ 'CD C:\FastPush\vnc7' & @CRLF & _ 'Net use \\%ipadress%\ipc$ /user:@ipaddress\%username% %password%' & @CRLF & _ 'call "C:\\FastPush\vnc7\vnc7.noicons.cmd" %ipadress%/ULTRA /noshortcut' & @CRLF & _ 'mkdir \\%ipadress%\c$\temp' $file_name = 'c:\login.cmd' $text = $template $text = StringReplace($text, '%ipadress%', $ipaddress) $text = StringReplace($text, '%username%', $username) $text = StringReplace($text, '%password%', $password) FileWrite($file_name, $text) Resources UDF ResourcesEx UDF AutoIt Forum Search 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