GianAutoitprogrammer Posted April 23, 2011 Share Posted April 23, 2011 Hellow, Why my script cant write the file... Here is the code: ;GUI ;1button = $save ;1edit = $editbox2 global $save1, $fileopened2 = 0, $Fileopen2 Case $SAVE1 And $FILEOPENED2 = 1 Filesetattrib(@Homedrive & "\config.sys", "-RASHOT") Filesetattrib(@Homedrive & "\config.sys", "+N") $FILEOPEN2 = @Homedrive & "\config.sys" FileDelete($FILEOPEN2) FileWrite($FILEOPEN2, GUICtrlRead($EDITBOX2)) _GUICtrlEdit_EmptyUndoBuffer($EDITBOX2) ;It cant write the modified file config.sys! I need help! Link to comment Share on other sites More sharing options...
reb Posted April 23, 2011 Share Posted April 23, 2011 Hellow, Why my script cant write the file...global $save1, $fileopened2 = 0, $Fileopen2 Case $SAVE1 And $FILEOPENED2 = 1In your example you have set $fileopened2 = 0 and your Case is expecting 1REB MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
GianAutoitprogrammer Posted April 23, 2011 Author Share Posted April 23, 2011 @reb No it will turn into 1 because I will click the Save Button in the GUI The editbox2 = will open the file C:\config.sys and you will edit the config.sys, If you edit it you must click the save button and then the C:\config.sys will be modified... Link to comment Share on other sites More sharing options...
Developers Jos Posted April 23, 2011 Developers Share Posted April 23, 2011 Try posting script that can be ran in stead of a portion that cannot function on it own. First of all I would start with error checking for each of the functions you do as currently you have no idea which function is successful and which fails. 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2011 Moderators Share Posted April 23, 2011 GianAutoitprogrammer,Add some debug code to your script like this so you can see what is going on: Case $SAVE1 And $FILEOPENED2 = 1 ; Check we get into the loop ConsoleWrite("We are in the loop" & @CRLF) $FILEOPEN2 = @Homedrive & "\config.sys" ; Check we set the attribs as we wish ConsoleWrite("Initial = " & FileGetAttrib($FILEOPEN2) & @CRLF) Filesetattrib($FILEOPEN2, "-RASHOT") ConsoleWrite("Next = " & FileGetAttrib($FILEOPEN2) & @CRLF) Filesetattrib($FILEOPEN2, "+N") ConsoleWrite("Final = " & FileGetAttrib($FILEOPEN2) & @CRLF) ; Now see if we delete the original Local $iRet = FileDelete($FILEOPEN2) ConsoleWrite("Deletion = " & $iRet & @CRLF) ; And finally see if we write to the new file $iRet = FileWrite($FILEOPEN2, GUICtrlRead($EDITBOX2)) ConsoleWrite("Writing = " & $iRet & @CRLF) _GUICtrlEdit_EmptyUndoBuffer($EDITBOX2)Now you can see if your commands are being successfully executed. What OS are you running? If it is Vista or Win7 I would hazard a guess that you are not amending the config.sys file at all. If that is the case, then try adding #RequireAdmin at the top of your script. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Developers Jos Posted April 23, 2011 Developers Share Posted April 23, 2011 mmm... scary 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2011 Moderators Share Posted April 23, 2011 Jos, And a good morning to you as well! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
somdcomputerguy Posted April 23, 2011 Share Posted April 23, 2011 The variables $fileopened2, $Fileopen2, $FILEOPENED2 and $FILEOPEN2 will probably conflict with each other. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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