TobiasSchade Posted March 13, 2019 Posted March 13, 2019 HI, I have a Provlem with my Script. I want to delet something in an ini File with a cmd command. This is my Script: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_AU3Check=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** If StringInStr($cmdlineRaw, "-sp") Then $Result = StringRight($cmdlineRaw, StringLen($cmdlineRaw)-StringInStr($cmdlineRaw, '-s')-2) IniWrite(@ScriptDir&'\test.ini', "Zugangsdaten", "Passwort", $Result) Exit ElseIf StringInStr($cmdlineRaw, "-rp") Then $IniR = IniRead(@ScriptDir&'\test.ini', "Zugangsdaten", "Passwort", '') ConsoleWrite($IniR&@CRLF) Exit ElseIf StringInStr($cmdlineRaw, "-dp") Then IniDelete(@ScriptDir & "\test.ini", "Zugangsdaten","Passwort") EndIf
Exit Posted March 13, 2019 Posted March 13, 2019 And what is the problem ? App: Au3toCmd UDF: _SingleScript()
TobiasSchade Posted March 13, 2019 Author Posted March 13, 2019 @Exit That it dosnt work I can t delet the Passwort with the cmd comand test.exe -dp The ather parts of the Sript works.
FrancescoDiMuro Posted March 13, 2019 Posted March 13, 2019 (edited) @TobiasSchade Are you sure that your If...ElseIf...EndIf is entering that side of the statement? You can check it putting a MsgBox() in before the IniDele() function. Then, we can't reproduce your script, so, if you could attach the .ini file, it would be helpful Edited March 13, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
TobiasSchade Posted March 13, 2019 Author Posted March 13, 2019 You can reproduce the Code if you make an ini withe the name test.ini and an AutoIT Script withe this code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_AU3Check=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** If StringInStr($cmdlineRaw, "-sp") Then $Result = StringRight($cmdlineRaw, StringLen($cmdlineRaw)-StringInStr($cmdlineRaw, '-s')-2) IniWrite(@ScriptDir&'\test.ini', "Zugangsdaten", "Passwort", $Result) Exit ElseIf StringInStr($cmdlineRaw, "-rp") Then $IniR = IniRead(@ScriptDir&'\test.ini', "Zugangsdaten", "Passwort", '') ConsoleWrite($IniR&@CRLF) Exit ElseIf StringInStr($cmdlineRaw, "-dp") Then IniDelete(@ScriptDir & "\test.ini", "Zugangsdaten","Passwort") EndIf And you must wirte in the ini: [Zugangsdaten] Passwort= ads Than you go in cmd in the directory with cd. After that you must write your AutoIT Scriptname.exe -dp for delet Passwort.
FrancescoDiMuro Posted March 13, 2019 Posted March 13, 2019 @TobiasSchade The password deletion seems to work fine. How do you call your script from Command Prompt? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
TobiasSchade Posted March 13, 2019 Author Posted March 13, 2019 @FrancescoDiMuro I write in cmd test.exe -dp and I get the error: Line 14 (File "C:\test\test.exe"): Eror: Unknown function name.
FrancescoDiMuro Posted March 13, 2019 Posted March 13, 2019 @TobiasSchade Are you running the last full AutoIt version? It is working by the way. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
TobiasSchade Posted March 13, 2019 Author Posted March 13, 2019 I have the last AutoIT Version and it dosnt work
BrewManNH Posted March 13, 2019 Posted March 13, 2019 I ran this script both compiled and uncompiled and it works for me both ways, using -dp it deletes the password and using -sp password it creates the line in the ini. So, I'm not seeing the issue you're seeing. It even works when I run it from a different directory than where the script and ini file are located. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
FrancescoDiMuro Posted March 13, 2019 Posted March 13, 2019 @BrewManNH Exactly Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
TobiasSchade Posted March 13, 2019 Author Posted March 13, 2019 ok it works I just dont safe it as exe with CUI instead
BrewManNH Posted March 13, 2019 Posted March 13, 2019 32 minutes ago, TobiasSchade said: k it works I just dont safe it as exe with CUI instead Huh, what? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Developers Jos Posted March 13, 2019 Developers Posted March 13, 2019 (edited) 1 hour ago, TobiasSchade said: ok it works I just dont safe it as exe with CUI instead It also works fine when compiled as CUI. So are the -sp and -rp working and the -dp is not working for you? Show the SciTE console output when you compile the script please. Jos Edited March 13, 2019 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
TobiasSchade Posted March 13, 2019 Author Posted March 13, 2019 The command -dp function. But my next comand dosnt work. This is my code: Quote #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_AU3Check=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Crypt.au3> #include <WinAPIFiles.au3> $sString = String("awdawdwadawd") If StringInStr($cmdlineRaw, "-sp") Then $Result = StringRight($cmdlineRaw, StringLen($cmdlineRaw)-StringInStr($cmdlineRaw, '-s')-2) IniWrite(@ScriptDir&'\test.ini', "Zugangsdaten", "Passwort", $Result) Exit ElseIf StringInStr($cmdlineRaw, "-rp") Then $IniR = IniRead(@ScriptDir&'\test.ini', "Zugangsdaten", "Passwort", '') ConsoleWrite($IniR&@CRLF) Exit ElseIf StringInStr($cmdlineRaw, "-dp") Then IniDelete(@ScriptDir & "\test.ini", "Zugangsdaten","Passwort") Exit ElseIf StringInStr($cmdlineRaw, "-test") Then IniWrite(@ScriptDir&'\test.ini', "Zugangsdaten", "Passwort", $dEncrypted) Exit ElseIf EndIf Example() Func Example() Local $sFilePath = @ScriptDir & "\NAS.ini"; Local $sFilter = "*NAS*" Local $sOutput = "" ; Store the output of StdoutRead to a variable. Local $sPass = IniRead($sFilePath, "Zugangsdaten", "Passwort", "Keine Datei gefunden") Local $sPasswort = IniRead($sFilePath, "Zugangsdaten", "Passwort", "Keine Datei gefunden") Local $dEncrypted = StringEncrypt(True, $sPasswort , 'KeyVerschlüsselung') IniDelete($sFilePath, "Zugangsdaten","Passwort") Local $sDecrypted = StringEncrypt(False, $dEncrypted, 'KeyVerschlüsselung') IniWrite($sFilePath, "Zugangsdaten", "Passwort", $dEncrypted) EndFunc Func StringEncrypt($bEncrypt, $sData, $sPassword) _Crypt_Startup() ; Start the Crypt library. Local $vReturn = '' If $bEncrypt Then ; If the flag is set to True then encrypt, otherwise decrypt. $vReturn = _Crypt_EncryptData($sData, $sPassword, $CALG_RC4) Else $vReturn = BinaryToString(_Crypt_DecryptData($sData, $sPassword, $CALG_RC4)) EndIf _Crypt_Shutdown() ; Shutdown the Crypt library. Return $vReturn EndFunc I want to encrypted the set Passwort if i write in cmd test.exe -test.
BrewManNH Posted March 13, 2019 Posted March 13, 2019 If you use any command line options when you run the script, you're never going to be able to run the Example function, because they (the command line options) all cause it to exit the script after running one of them. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Developers Jos Posted March 13, 2019 Developers Posted March 13, 2019 1 hour ago, TobiasSchade said: The command -dp function. But my next comand dosnt work. I can only handle one thing at a time and am missing requested information. So please provide all information so we can solve the initial issue before continuing to something else. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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