Jump to content
Sign in to follow this  
RedemptionBlue

(SOLVED): Network Login Script (UNSOLVED): Debugging

Recommended Posts

Hey guys,

I am very new to using AutoIt and wrote my first little script today after reading bits and pieces on the docs.

The script is designed to make an ugly batch operation a bit more user friendly for the people in the office.

I have a batch file that consists of:

@echo off
net use B: /delete
net use B: \\10.10.10.10\Share /user:domain\username

It is used to log a user onto a secure share drive on my NAS. I have spoofed the share location etc. however.

My AutoIt Script is:

Local $passwd = InputBox("Attempting to Access B:", "Enter your password.", "", "*","M")
Run("C:\Users\User\Desktop\login.bat")
WinWaitActive("C:\Windows\system32\cmd.exe")
Send($passwd)

Now this works fine, however once I input my password into the GUI and it Sends that Password to the cmd window, I cannot make it send an "ENTER" Keystroke.

It isn't a HUGE issue as I can manually press enter once the cmd window shows up, but I would like it to input the password and do the carriage return straight away. I have tried using

Send("{ENTER}")
, and it returns an error. I have tried changing the way I implement the sending of {ENTER} in as many ways as I can think of.

I would greatly appreciate it if anyone can help me on this. Also, if anyone knows of a way to run the cmd window silently but still be able to send the password to it that would be even better!

Cheers

Edited by RedemptionBlue

Share this post


Link to post
Share on other sites

Hello!

Welcome to the forum.

You could send the password as a command-line parameter

ShellExecute("C:UsersUserDesktoplogin.bat", $passwd)

and then modify the batch file to utilize the passed parameter:

net use B: 10.10.10.10Share /user:domainusername %1

(I have no access to a network share presently, you may need to wrap the %1 in quotes)

But, I'd suggest it might be cleaner to eliminate the batch file entirely and execute the DOS commands directly from your Autoit script.

Edit: Regarding your second question. Look at the helpfile for InputBox(). Many Autoit commands set a special @error variable after execution. Test the value of @error after the call to InputBox() and react accordingly.

Edited by Spiff59

Share this post


Link to post
Share on other sites

Hi Spiff,

Thank you for your swift reply.

I would love to get rid of the batch alltogether, it would be much cleaner indeed.

I have not found too many tutorials as to how to use the AutoIt API and I keep seeing references to the @error value, yet I do not know how to check it's value, utilise it's value or even know anything about it other than the fact that it is returned by many functions.

I also do not quite get what you mean by sending the password as a command line parameter. The Batch file does the share authentication process perfectly, the reason I wanted to use AutoIt is because I work in an office and the Black and white CMD interface is scary for some of the end users. A 'nicer' GUI would be ideal.

Thank you for any help, it is all appreciated, learning is always great!

Share this post


Link to post
Share on other sites

Batch files allow for "command-line parameters" simply parameters included on the command-line. So, if from a command prompt you typed "login.bat parameter1 parameter2" then inside the batch file you could reference the parameters typed on the command line by using the built-in variables %1, %2, %3, etc. A line in a batch file that was:

@echo The first command-line parameter is: %1

would display

The first command-line parameter is: parameter1

The "net use" command allows for optional password parameter, instead of prompting the user.

So, we used ShellExecute to launch login.bat and pass it the value of $passwd. Inside the batch file we plugged that parameter (%1) into the proper location of the "net use" command, so it won't need to ask the user for it.

@error behaves much the same as any typical user-created variable that begins with $.

If @error = 2 Then Msgbox(0,"", "The InputBox timed out!")

or for a different look:

If @error = 1 Then
    Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
    Sleep(2000)
    Exit
Endif

Edit: The helpfile is a pretty good resource. You can find some basic stuff by googling "Autoit tutorial wiki"

Edited by Spiff59

Share this post


Link to post
Share on other sites

Thank you Spiff.

I managed to make it work using the command-line parameter method.

I would still like to eliminate the need for the .bat but I have played with executing the net use straight out of AutoIt and can't seem to get it.

I will use my knowledge gained today to work on my logout script now.

Thank you again. Is there a way that I can give you "rep" or something? You have been very helpful.

Cheers

Share this post


Link to post
Share on other sites

Hi, RedemtionBlue. Have you taken a look at DriveMapAdd and DriveMapDel in the help file? It appears these could do the job of eliminating the batch file for you. Something like this, I would think:

DriveMapDel("B:")
DriveMapAdd("B:", '<path to share>', 8, "domain" & @UserName);<--8 automatically shows the authentication box for you
Edited by JLogan3o13

Share this post


Link to post
Share on other sites

Having Trouble with DriveMapAdd.

It keep returning @error = 1

Here is my Code at the moment.

Local $user = InputBox("B:", "Enter your username", "", "", 215,137)
Local $passwd = InputBox("Attempting to Access B:", "Please enter your password", "", "*",215,137)
If @error = 1 Then
Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
Sleep(2000)
Exit
ElseIf @error = 2 Then
Msgbox(0,"", "The InputBox timed out!")
EndIf
DriveMapDel("B:")
DriveMapAdd("B:", '\\10.0.0.20\Beaches', 8, "domain\" & $user, $passwd)
If @error = 1 Then
MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error")
Exit
ElseIf @error = 2 Then
MsgBox(0, "Failure", "Failed to Connect to B: - Access is Denied")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Failure", "Failed to Connect to B: - The Drive is Already Assigned")
Exit
ElseIf @error = 4 Then
MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Device Name")
Exit
ElseIf @error = 5 Then
MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Remote Share")
Exit
ElseIf @error = 6 Then
MsgBox(0, "Failure", "Failed to Connect to B: - Incorrect Password")
Exit
EndIf
MsgBox(1, "B:", "You have been logged into B:")

Every single time, I get the MsgBox that I set for @error = 1. Any Ideas why, is my code wrong(quite likely)?

Share this post


Link to post
Share on other sites

If @error = 1 what's the value of @extended then?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

What can I do to check the value or @extended, just

MsgBox(0, "Extended Check", "The value of @extended is " & @extended)

?

Cheers

EDIT: Used the code I just mentioned and @extended printed as 0.

Edited by RedemptionBlue

Share this post


Link to post
Share on other sites

Use

If @error = 1 Then MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error, @extended = " & @extended)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Does it make sense to set the flag to 8 (Show authentication dialog if required) when you provide userid and password?

Could you try:

DriveMapAdd("B:", '10.0.0.20Beaches', 0, "domain" & $user, $passwd)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

My script works sometimes but not all the time.

Sometimes it logs me in no worries, other times it returns @error = 1 so I get the unknown error message with a value of @extended = 1219.

Any ideas? I think it is a windows networking issue because when I try to do the DOS command for adding a drive I get an error regarding mapped drives and multiple users, although often I am only logging in from the singular machine.

Windows' networking needs a rethink, I also get errors where it refuses to delete a mapped drive but also won't reconnect either. (Sorry i will stop ranting about windows as this is not the place).

My Code as of now:

Local $user = InputBox("B:", "Enter your username", "", "", 215,137)
If @error = 1 Then
    Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
    Sleep(2000)
    Exit
ElseIf @error = 2 Then
Msgbox(0,"", "The InputBox timed out!")
EndIf

Local $passwd = InputBox("Attempting to Access B:", $user & ", please enter your password", "", "*",215,137)
If @error = 1 Then
    Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
    Sleep(2000)
    Exit
ElseIf @error = 2 Then
Msgbox(0,"", "The InputBox timed out!")
EndIf
DriveMapDel("B:")
DriveMapAdd("B:", '10.0.0.20Beaches', 0, "domain" & $user, $passwd)
If @error = 1 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error Code: " & @extended)
   Exit
ElseIf @error = 2 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Access is Denied")
   Exit
ElseIf @error = 3 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - The Drive is Already Assigned")
   Exit
ElseIf @error = 4 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Device Name")
   Exit
ElseIf @error = 5 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Remote Share")
   Exit
ElseIf @error = 6 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Incorrect Password")
   Exit
EndIf
MsgBox(1, "B:", "You have been logged into B:")

The batch code that I use and sometimes get the error(Could be related):

net use B: /delete
net use B: 10.0.0.20Beaches /user:domainusername

FYI, username etc are spoofed.

Cheers

Share this post


Link to post
Share on other sites

@extended = 1219 is a WinAPI error code, see the remarks at DriveMapAdd

Multiple connections to a server or shared resource by the same user, using more

than one user name, are not allowed. Disconnect all previous connections to the

server or shared resource and try again..

So you're trying to map a network drive with invalid credentials.

Here's a list for future reference: System Errors


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites

The credentials are 100% correct.

There seems to be problems with windows and authentication of these drives sometimes.

The error regarding bad creds is inconsistent and often the script will just work.

I find after a restart, sometimes it is fixed.

Also, there are only 3 users that have access to the drive and for the sake of well... because I can, I want to make it so if the username of either clare, ric or tony is not entered then the script gives you a MsgBox() and Exits.

Here is my code for it that I tried, but I have looked around on the forums, tutorials and google only to not find anyone else explaining how to do this.

Local $user = InputBox("B:", "Enter your username", "", "", 215,137)
If @error = 1 Then
    Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
    Sleep(2000)
    Exit
ElseIf @error = 2 Then
Msgbox(0,"", "The InputBox timed out!")
EndIf

If $user <> tony and $user <>clare and $user <> ric Then
Msgbox(0, "Failure", "The username is not recognised")
Exit
EndIf

Thanks for that

Share this post


Link to post
Share on other sites

Thank you for all the help so far, my "end-product" is getting closer to completion so to speak.

Just trying to make it so that if the username supplied is not one of the 3 that are allowed to gain access then it says something like "Unknown Username" Or what not.

My entire script is:

Local $user = InputBox("B:", "Enter your username", "", "", 215,137)
If @error = 1 Then
    Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
    Sleep(2000)
    Exit
ElseIf @error = 2 Then
Msgbox(0,"", "The InputBox timed out!")
EndIf

#cs
If $user <> tony and $user <>clare and $user <> ric Then
Msgbox(0, "Failure", "The username is not recognised")
Exit
EndIf
#ce

Local $passwd = InputBox("Attempting to Access B:", $user & ", please enter your password", "", "*",215,137)
If @error = 1 Then
    Tooltip("Script Cancelled by User", @DesktopWidth / 2, @DesktopHeight / 2, "Network Login Script", 0, 2)
    Sleep(2000)
    Exit
ElseIf @error = 2 Then
Msgbox(0,"", "The InputBox timed out!")
EndIf
DriveMapDel("B:")
DriveMapAdd("B:", '\\10.0.0.20\Beaches', 0, "domain\" & $user, $passwd)
If @error = 1 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Unknown Error Code: " & @extended & @CRLF & "Please contact your IT Support")
   Exit
ElseIf @error = 2 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Access is Denied")
   Exit
ElseIf @error = 3 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - The Drive is Already Assigned")
   Exit
ElseIf @error = 4 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Device Name")
   Exit
ElseIf @error = 5 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Invalid Remote Share")
   Exit
ElseIf @error = 6 Then
   MsgBox(0, "Failure", "Failed to Connect to B: - Incorrect Password" & @CRLF & "If you have forgotten your password please contact IT Support")
   Exit
EndIf
MsgBox(1, "B:", "You have been logged into B:")

As you can see I have placed my attempt at the username authentication in #cs/ce tags.

If I cannot do it in the simpler format that I have attempted I will just make it so that it is an if statement where if $user = tony Then execute script, else if $user = clare Then execute script, else if $user = ric execute script, else Exit.

I would rather not do that as I am a Java programmer and it seems to me like just sloppy code but I just do not quite have the syntax/semantics of if statements in autoit fully understood.

Cheers

Share this post


Link to post
Share on other sites

If you have only 3 usernames then your code is fine (for me).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If I get rid of the #cs/ce tags on the username authentication code then I get an error on running the script. I will get back to a machine with the script and autoit on it and I will get back to you with the error.

Share this post


Link to post
Share on other sites

You need quotes around the user names:

If $user <> "tony" and $user <> "clare" and $user <> "ric" Then
    Msgbox(0, "Failure", "The username is not recognised")
    Exit
EndIf

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-10-24 - Version 1.4.14.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (NEW 2019-11-07 - Version 1.3.0.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki

 

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  

  • Similar Content

    • By Luigi
      Greetings,
      I need write a command line to run an .exe with parameters, one this parameters is a password with special characters  like:   [ ] \ "  etc.
      The password is write between double cotes too.
      When run this command line, catch error.
      I buid this function, sometimes run ok, others show error.

      Someone can any idea?

      Best ragards
      #include <Array.au3> Global $G_AIX_DEFAULT_PASSWORD = "******" Func Scape_Word_To_MSDOS($var = "") ;~ https://www.robvanderwoude.com/escapechars.php Local $aCharacters[][2] = [ _ ["%", "%%"], _ ["^", "^^"], _ ["&", "^&"], _ ["<", "^<"], _ [">", "^>"], _ ["|", "^|"], _ ["'", "^'"], _ ["`", "^`"], _ [",", "^,"], _ [";", "^;"], _ ["=", "^="], _ ["(", "^("], _ [")", "^)"], _ ["!", "^^!"], _ ["\", "\\"], _ ["[", "\["], _ ["]", "\]"], _ ['"', '\"""'], _ [".", "\."], _ ["*", "\*"], _ ["?", "\?"] _ ] Local $iSearch $var = StringSplit($var, "", $STR_NOCOUNT) Local $iSize = UBound($var, $UBOUND_ROWS) - 1 For $ii = 0 To $iSize $iSearch = _ArraySearch($aCharacters, $var[$ii]) If $iSearch >= 0 Then $var[$ii] = $aCharacters[$iSearch][1] Next Return _ArrayToString($var, "") EndFunc ;==>Scape_Word_To_MSDOS Local $password = "-Dk5iFB2UjOt[-x|""" & "" Local $password_scape = Scape_Word_To_MSDOS($password) ConsoleWrite("[" & $password & "]" & @LF) ConsoleWrite("[" & $password_scape & "]" & @LF)  
       
    • By TheSaint
      TeraCopy Timer - A program of mine, front end really, that I have been working on (on & off) for some time, but not shared here before, that I recall. Third party program TeraCopy is required.
      Many of you will be familiar with TeraCopy, and it has been discussed here at AF on several occasions, in various sub forums, including Chat.
      BE ADVISED - I still use an older version of TeraCopy (v2.27), a goody but an oldy, so have only tested my program with that. It may work with the newer v3.xx, or may be easily adjusted to do so, but I have not yet gone that route. Likewise, I only use it with Win 7 and Win XP, but I don't imagine there should be any issues with newer Windows. Add to that, my program being devised and created in AutoIt v3.3.0.0.
      So what is TeraCopy Timer and why might you need it?
      --------------------------------------------------------------------------------------
      Those familiar with TeraCopy use, know you can run multiple copy or move jobs either simultaneously or concurrently (one immediately after another has finished). With the free version at least, you have no control over precise order or timing, and no way to deal (without manual interaction) with the pesky Thumbs.db files in Win XP. TeraCopy Timer allows you to do all those things, and in a batch fashion.
      --------------------------------------------------------------------------------------
      Some screenshots and brief explanation
      Main Window
      Minimalist Window
      This new WAIT feature is the simplest and best way to use the program generally (in my view) ... but check out the following, as it is not always the case.
      Advanced Delay Window
      WARNING - It should go without saying, that you take all the usual precautions. For instance, don't use move with the only copy you have of precious files. BACKUP BACKUP BACKUP! Don't hold me liable for anything, except for being a nice guy who likes to share.
      TeraCopy Timer v3.1.zip  (see detail at Post #37)
      Enjoy!
      OLDER DOWNLOADS
      P.S. I am not affiliated in any way with those who created and provide the excellent third party program - TeraCopy.
    • By nacerbaaziz
      good morning sirs.
      please i have a request from you.
      i have an variable to Read a data from a file
      this data is Encrypted
      and when i read it i Decrypte it.
      for that i need a function to Write a ini data to string.
      ;#Function# ===================================================================================================================== ; Name............: _IniReadFromString ; Description.....: Returns the value of a key in a specific section of an ini-formatted string ; Syntax..........: _IniReadFromString($szInput, $szSection, $szKey, $Default) ; Parameters......: ;   $szInput - The string that contains data in ini format ;   $szSection   - The sectionname (just as in IniRead) ;   $szKey   - The keyname (just as in IniRead) ;   $Default - The default value if the key does not exist or reading failed (just as in IniRead) ; Return values ..: ;   Success  - Returns the read value ;   Failure  - Returns $Default ; Author .........: FichteFoll ; Remarks ........: Works for Unicode as well as for ANSI ; Related ........: IniRead, _IniReadSectionFromString ; Link ...........; See on top ; Example ........; $var = _IniReadFromString(StringFormat("[Sect]\r\nMyKey1=value1\r\nMyKey2=value2"), "Sect", "MyKey2", "no_value") ; =============================================================================================================================== Func _IniReadFromString($szInput, $szSection, $szKey, $Default) $szInput = StringStripCR($szInput) ;~  Local $aRegMl = StringRegExp($szInput, "\[" & __StringEscapeRegExp($szSection) & "\]\n+(?:[^\[].*?=.*\n)*" & __StringEscapeRegExp($szKey) & "=(.*)\n?(",3) Local $aRegMl = StringRegExp($szInput, "\[" & __StringEscapeRegExp($szSection) & "\]\n+(?:[^\[].*?=.*\n)*" & __StringEscapeRegExp($szKey) & "=(.*)\n?", 3) If @error Then Return SetError(1, 0, $Default) ; key not found    Return $aRegMl[0] EndFunc;==>_IniReadFromString ; ############################################################################################################################### ; =============================================== ; = Internal Use Only ; =============================================== Func __StringEscapeRegExp($szExp) Return StringRegExpReplace($szExp, "([\(\)\[\]\{\}\\\/\?\.\\|\+])", "\\$1") ; ()[]{}\/?.|+ EndFunc;==>__StringEscapeRegExp like this  function Read the ini from string.
       
       
      please ihelp me
      thanks in advance
    • By vin1
      i have a script that selects  a text file and deletes a line (text input required) in the text file selected
      i have to make it remove all lines found on a file i name, toRemoveLines.txt
      it has to remove lines from all text files found in a folder
      this is the script that has to be modified
      where it says "select file" it has to be "select folder"
      where it says "line text input" it has to be all lines from a text file
      #Include <File.au3> Global $success = False $file_name = FileOpenDialog("Select file", @ScriptDir, "All files (*.*)", 1+4) $line_text_input = InputBox("Line's text", "Line must contain following text:", "line contains this text") $file_count_lines = _FileCountLines($file_name) for $i = 0 to $file_count_lines $Lines_text_output = FileReadLine($file_name, $i) if StringInStr($Lines_text_output, $line_text_input) then _FileWriteToLine($file_name, $i, "", 1) $success = True ExitLoop EndIf Next if $success = True Then MsgBox(0, "Success", "Line has been deleted") Else MsgBox(0, "Failure", "Line wasn't found") EndIf  
×
×
  • Create New...