Marius-Ligon Posted February 5, 2019 Posted February 5, 2019 Hi I want to wirte an AutoIT skript in witch I can set an Passwort if i send an cmd comand. I have writen some skript where i safe an Passwort form an GUI to an ini. My problem is, that i dosn´t now how to use cmd in AutoIT. I want to wirte: Test.au3 -s testPass ;//-s for set Passwort testPass in the ini data (IniWrite($sFilePath, "Pass", "Passwort", ?)) I want to wirte: Test.au3 -r ;//-r for read the Passwort (testPass)
Marius-Ligon Posted February 5, 2019 Author Posted February 5, 2019 Spoiler f $CmdLine[0] = 0 Then help() If $CmdLine[1] = "/?" Then help() If $CmdLine[1] = "?" Then help() I don t now how to use that
Subz Posted February 5, 2019 Posted February 5, 2019 Its not very secure way to keep your password, would recommend using encryption, here is a basic example of what you want to do, just compile the file as an exe and you can use -s or -r. #NoTrayIcon Local $sGetPwd = Null, $sSetPwd = Null Local $g_sFilename = @ScriptDir & "\Filename.ini" If $CmdLine[0] >= 1 Then $sSetPwd = _CmdGetValue("s") <> Null ? _CmdGetValue("s") : Null $bGetPwd = _CmdLine_Exists("r") EndIf If $sSetPwd <> Null Then IniWrite($g_sFilename, "Pass", "Password", $sSetPwd) If $bGetPwd Then MsgBox(4096, "Password", IniRead($g_sFilename, "Pass", "Password", Null)) Func _CmdGetValue($sCmdLine, $vResult = Null) For $i = 1 To $CmdLine[0] If $CmdLine[$i] = "/" & $sCmdLine Or $CmdLine[$i] = "-" & $sCmdLine Or $CmdLine[$i] = "--" & $sCmdLine Then If $CmdLine[0] >= $i + 1 Then If StringLeft($CmdLine[$i + 1], 1) = "/" Or StringLeft($CmdLine[$i + 1], 1) = "-" Or StringLeft($CmdLine[$i + 1], 2) = "--" Then Return $vResult Else Return $CmdLine[$i + 1] EndIf EndIf EndIf Next Return $vResult EndFunc Func _CmdLine_Exists($sCmdLine) For $i = 1 To $CmdLine[0] If $CmdLine[$i] = "/" & $sCmdLine Or $CmdLine[$i] = "-" & $sCmdLine Or $CmdLine[$i] = "--" & $sCmdLine Then Return True EndIf Next Return False EndFunc
Marius-Ligon Posted February 5, 2019 Author Posted February 5, 2019 what is the cmd command? This is my first tie that I use that so sorry but I dosn t now how to make that right.
TheXman Posted February 5, 2019 Posted February 5, 2019 @Marius-Ligon In the Help file, look at the section under "Using AutoIt", called "Command Line Parameters. You will see how to get access parameters passed to your script. ($CmdLine array and $CmdLineRaw). CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Marius-Ligon Posted February 5, 2019 Author Posted February 5, 2019 @TheXman I want to now what did i write in cmd for a key to start something in the AutoIT skript?
TheXman Posted February 5, 2019 Posted February 5, 2019 1 minute ago, Marius-Ligon said: I want to now what did i write in cmd for a key to start something in the AutoIT skript? Sorry, I don't understand your question. Can you ask it in a different or more detailed way? CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Marius-Ligon Posted February 5, 2019 Author Posted February 5, 2019 @TheXman I have my cmd and i go to C:\test\1 test.au3 I don´t now what I must write behind that
TheXman Posted February 5, 2019 Posted February 5, 2019 (edited) If you are asking how can you test it in the editor, then if you are using the full scite editor, you can hit Shift+F8 to enter parameters that you want to pass to your script. If you have compiled your script, the you would pass parameters to it the way you would with any other console application. How you process the command line is up to you. If you want to run the .au3 file from the command line instead of a complled .exe, then go to the same section of the help file that I referenced earlier. It shows you the syntax for running .au3 scripts. Edited February 5, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Marius-Ligon Posted February 5, 2019 Author Posted February 5, 2019 @TheXman Have you an example for me ? Quote #NoTrayIcon Local $sGetPwd = Null, $sSetPwd = Null Local $g_sFilename = @ScriptDir & "\Filename.ini" If $CmdLine[0] >= 1 Then $sSetPwd = _CmdGetValue("s") <> Null ? _CmdGetValue("s") : Null $bGetPwd = _CmdLine_Exists("r") EndIf If $sSetPwd <> Null Then IniWrite($g_sFilename, "Pass", "Password", $sSetPwd) If $bGetPwd Then MsgBox(4096, "Password", IniRead($g_sFilename, "Pass", "Password", Null)) Func _CmdGetValue($sCmdLine, $vResult = Null) For $i = 1 To $CmdLine[0] If $CmdLine[$i] = "/" & $sCmdLine Or $CmdLine[$i] = "-" & $sCmdLine Or $CmdLine[$i] = "--" & $sCmdLine Then If $CmdLine[0] >= $i + 1 Then If StringLeft($CmdLine[$i + 1], 1) = "/" Or StringLeft($CmdLine[$i + 1], 1) = "-" Or StringLeft($CmdLine[$i + 1], 2) = "--" Then Return $vResult Else Return $CmdLine[$i + 1] EndIf EndIf EndIf Next Return $vResult EndFunc Func _CmdLine_Exists($sCmdLine) For $i = 1 To $CmdLine[0] If $CmdLine[$i] = "/" & $sCmdLine Or $CmdLine[$i] = "-" & $sCmdLine Or $CmdLine[$i] = "--" & $sCmdLine Then Return True EndIf Next Return False EndFunc That dosn´t work
TheXman Posted February 5, 2019 Posted February 5, 2019 9 minutes ago, Marius-Ligon said: That dosn´t work CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
careca Posted February 5, 2019 Posted February 5, 2019 3 hours ago, Marius-Ligon said: I want to wirte: Test.au3 -s testPass ;//-s for set Passwort testPass in the ini data (IniWrite($sFilePath, "Pass", "Passwort", ?)) I want to wirte: Test.au3 -r ;//-r for read the Passwort (testPass) If StringInStr($cmdlineRaw, "-s") Then $Result = StringRight($cmdlineRaw, StringLen($cmdlineRaw)-StringInStr($cmdlineRaw, '-s')-2) IniWrite(@ScriptDir&'\1.ini', "Pass", "Password", $Result) Exit ElseIf StringInStr($cmdlineRaw, "-r") Then $IniR = IniRead(@ScriptDir&'\1.ini', "Pass", "Password", '') ConsoleWrite($IniR&@CRLF) Exit EndIf Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
Marius-Ligon Posted February 5, 2019 Author Posted February 5, 2019 @careca Why did you need that -2 ? $Result = StringRight($cmdlineRaw, StringLen($cmdlineRaw)-StringInStr($cmdlineRaw, '-s')-2)
Moderators JLogan3o13 Posted February 6, 2019 Moderators Posted February 6, 2019 READ...THE...HELP...FILE "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
spudw2k Posted February 6, 2019 Posted February 6, 2019 To be fair, the help file doesn't say why the -2 is used in the specific line of code you made. @Marius-Ligon Perhaps you can try it with and without the -2 and see the difference for yourself? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
careca Posted February 6, 2019 Posted February 6, 2019 (edited) 11 hours ago, Marius-Ligon said: @careca Why did you need that -2 ? In your defense, if you dont have much experience in this language, this might be confusing even after checking the help file. So the stringright returns a number of characters from the right hand side of a string. first parameter is the original string, the second is the count. So in the count part we have the stringlen (lenght) of the original string minus the position of '-s', given by the stringinstr, minus 2 because we dont want to retrieve the '-s' or any bit of it. So if you remove the -2 you get the 'S', a space, and the portion of the string you want. Edited February 6, 2019 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe
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