imacrazyballoono Posted June 20, 2006 Posted June 20, 2006 For some reason that I dont know, the filewrite part of this script will not work in a non admin account. Why? $time = IniRead("C:\Program Files\Timer\config.txt", "default", "time", "0") if $time = 0 then MsgBox(4096, "Result", "time not found") endif $file = fileopen("C:\Program Files\Timer\timer.txt", 2) filewrite($file, $time) fileclose($file)
AutoItKing Posted June 20, 2006 Posted June 20, 2006 (edited) That's weird. And just to make it a little shorter: $time = IniRead("C:\Program Files\Timer\config.txt", "default", "time", "0") If $time = 0 Then MsgBox(4096, "Result", "time not found") $file = FileOpen("C:\Program Files\Timer\timer.txt", 2) FileWrite($file, $time) FileClose($file) Edited June 20, 2006 by AutoItKing http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script]
nfwu Posted June 20, 2006 Posted June 20, 2006 What kind of non-admin account is it? #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 just a limited user. I think that is the problem. When i run the script on my admin account, it works fine, but when i run the same one on the limited one, it gives an error.
Don N Posted June 20, 2006 Posted June 20, 2006 On your admin acct you can change the user permissions so that they can write to that folder. This would probably be easiest if you intend to keep running scripts on a limited acct. Or you could run the script as an admin from the limited acct using RunAs. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 (edited) I need this script to be run when the user logs in. I dont think its a permissions error. Ill go get the error right now. EDIT: Line 14 filewrite($file, $time) error: invalid file handle used. Edited June 20, 2006 by imacrazyballoono
Don N Posted June 20, 2006 Posted June 20, 2006 (edited) Check to make sure FileOpen() does not return -1. $time = IniRead("C:\Program Files\Timer\config.txt", "default", "time", "0") If $time = 0 Then MsgBox(4096, "Result", "time not found") $file = FileOpen("C:\Program Files\Timer\timer.txt", 2) If $file <> "-1" Then FileWrite($file, $time) FileClose($file) Else MsgBox( 0, "", "Error opening the file" ) EndIf That should tell you if there was an error openign the file itself. EDIT: Fixed issue with code... Edited June 20, 2006 by Don N _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 (edited) do you need an endif after the first, or only, if statement? EDIT: it gave the error, does that mean it is a permission thing? Edited June 20, 2006 by imacrazyballoono
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 Now its just being stupid. I logged off the account and changed permissions on the file then logged back into it and it doesnt give the "error opening the file" error. I ran this script and it worked fine with not errors. Why is it not working??? The second script is the one that isn't workng $time = IniRead("C:\Program Files\Timer\config.txt", "default", "time", "0") if $time = 0 then MsgBox(4096, "Result", "time not found") endif $file = fileopen("C:\Program Files\Timer\timer.txt", 2) filewrite($file, $time) fileclose($file) $time = IniRead("C:\Program Files\Timer\config.txt", "default", "time", "0") If $time = 0 Then MsgBox(4096, "Result", "time not found") $file = FileOpen("C:\Program Files\Timer\timer.txt", 2) If $file <> "-1" Then FileWrite($file, $time) FileClose($file) Else MsgBox( 0, "", "Error opening the file" ) EndIf FileWrite($file, $time) FileClose($file)
Don N Posted June 20, 2006 Posted June 20, 2006 See my modified post above, I included the FileWrite() twice. When you run the script do you get the MsgBox or does it try to write to the file? _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 I have no idea what I or you did, but it works now. My original script works. Thanks for your help.
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 I'm not sure, but it works. Does the format matter of the file as long as the text inside the file is the same?
NELyon Posted June 20, 2006 Posted June 20, 2006 no idea. but in the help file it said "The name of the .INI file you are reading" under INIread
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 I should probably change it to an ini file just to make sure there are no repercussions.
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