Jump to content

Recommended Posts

Posted

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)
Posted (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 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]
Posted

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

Posted (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 by imacrazyballoono
Posted (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 by Don N

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Posted

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)
Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...