Ownership?

New to FreeBASIC? Post your questions here.
cavelamb
Posts: 25
Joined: Jan 04, 2010 9:03
Location: earth
Contact:

Ownership?

Postby cavelamb » Jan 27, 2019 22:14

Win 7 64 bit
new Freebasic Install

Once my code compiles and creates an EXE file, I run into trouble.
I can not compile again

Can't erase the EXE.
A box comes up saying I need permission to perform this action.

Sometimes it offers "Yes"
Sometime "Try again" - which never works.

When that happens, clicking on the compiled program gets:
Windows cannot access the specified device, path, or file.
You may not have appropriate permissions to access the item.

A couple of minutes later is sometimes disappears!

What's going on???
badidea
Posts: 2076
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Ownership?

Postby badidea » Jan 27, 2019 22:21

Virus-scanner busy with the file?
I remember having those kind of issues with Win7. Not sure if was the virus-scanner or windows itself doing something very important with the file. Win8.1 did not seem to have the issue. Haven't tried Win10 yet, mostly on linux here.
coderJeff
Site Admin
Posts: 3186
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Ownership?

Postby coderJeff » Jan 28, 2019 2:34

Is the program still running? Check task manager.

A program that has an endless loop and no display compiled with fbc -s gui program.bas, will display nothing, lock the executable file from being deleted, and run forever until you kill it.
cavelamb
Posts: 25
Joined: Jan 04, 2010 9:03
Location: earth
Contact:

Re: Ownership?

Postby cavelamb » Jan 28, 2019 16:12

Not the virus scanner, and no, the program is not still running.

I guess I'll remove and reinstall...
MrSwiss
Posts: 3538
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Ownership?

Postby MrSwiss » Jan 28, 2019 16:20

If you are re-installing anyway, then:
    1) download the .zip file (for Windows, NOT the Installer)
    2) create a new folder (e.g. C:\FreeBASIC\), maybe add a version sub-dir, like '1050_32' or '1050_64'
    3) unzip to that Dir ... (should solve any problems)
UEZ
Posts: 582
Joined: May 05, 2017 19:59
Location: Germany

Re: Ownership?

Postby UEZ » Jan 28, 2019 17:15

Are you sure that the compiled exe is not still running in the background?
When you compile the code as GUI but has at the end a Sleep then the program waits do get a key pressed.
Last edited by UEZ on Jan 28, 2019 21:16, edited 1 time in total.
cavelamb
Posts: 25
Joined: Jan 04, 2010 9:03
Location: earth
Contact:

Re: Ownership?

Postby cavelamb » Jan 28, 2019 19:35

I think I've got it working.
Deleted the previous install (64 bit zip) and reinstalled from the win32bit exe.

Does the EXE installer dink with the registry?


(edit)

Spoke too soon...

Still don't have access to the compiled file _ AFTER running it.
(and no, it's not still running)

Still getting permission denied when trying to recompile again.
MrSwiss
Posts: 3538
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Ownership?

Postby MrSwiss » Jan 28, 2019 20:06

cavelamb wrote:Does the EXE installer dink with the registry?
That's not the point.

It tries by default, to install to Program Files (x86), which then causes troubles.
(usually, the ordinary user has not enough rights there)
Tourist Trap
Posts: 2880
Joined: Jun 02, 2015 16:24

Re: Ownership?

Postby Tourist Trap » Jan 28, 2019 20:09

cavelamb wrote:Win 7 64 bit
new Freebasic Install

Once my code compiles and creates an EXE file, I run into trouble.
I can not compile again

Can't erase the EXE.
A box comes up saying I need permission to perform this action.

Sometimes it offers "Yes"
Sometime "Try again" - which never works.

When that happens, clicking on the compiled program gets:
Windows cannot access the specified device, path, or file.
You may not have appropriate permissions to access the item.

Hello,
something is unclear to me. Do every programs you compile in fb are in trouble, or just one? Also, where is your program on the disk? Did you try a quickrun in FBIDE for example? Did you try another computer to run your exe on?
And finally, where did you get your fb version?
All of this can influe, as well of course as your antivirus. Personnally I would use quickrun on fbide + -exx option because it's always what I do, I don't see what can be causing what you describe. I would try to change something from the context, like the ide, the directory of execution etc...
UEZ
Posts: 582
Joined: May 05, 2017 19:59
Location: Germany

Re: Ownership?

Postby UEZ » Jan 28, 2019 20:32

cavelamb wrote:I think I've got it working.
Deleted the previous install (64 bit zip) and reinstalled from the win32bit exe.

Does the EXE installer dink with the registry?


(edit)

Spoke too soon...

Still don't have access to the compiled file _ AFTER running it.
(and no, it's not still running)

Still getting permission denied when trying to recompile again.


Maybe it is a good idea to share the code that we can test it, too.
cavelamb
Posts: 25
Joined: Jan 04, 2010 9:03
Location: earth
Contact:

Re: Ownership?

Postby cavelamb » Jan 28, 2019 21:03

I doubt it's anything in the code, it's too simple
But here anyway...

When I try to delete the exe I get a message:
Title = File In Use

The action can't be completed because the file is open in Syste,
Close the file and try again.

Which doesn't work and repeats itself.

But the Windows Task Manager doesn't list it.





Code: Select all

' brute stupid movie title collector and sorter
'  R Lamb  1/27/2018
'
#lang "fblite"
OPTION GoSub

Dim shared FileIn As string, strA(2048)As String, Pad As String
Dim Fcnt As Integer, X As Integer, NumRec As Integer

Dim A$(2048)

Pad$ = String$(60,"_")
Fcnt = 0

FileIn$ = "Movies-1-1.txt"
Print "Reading: "; FileIn$
OPEN FileIn$ FOR INPUT AS #1
WHILE NOT EOF(1)
  fcnt = fcnt + 1
  LINE INPUT #1, A$(fcnt)
  A$(fcnt) = Left$(A$(fcnt) + Pad$, 40) + " < 1-1"
WEND
Close


FileIn$ = "Movies-2-1.txt"
Print "Reading: "; FileIn$
OPEN FileIn$ FOR INPUT AS #1
WHILE NOT EOF(1)
  fcnt = fcnt + 1
  LINE INPUT #1, A$(fcnt)
  A$(fcnt) = Left$(A$(fcnt) + Pad$, 40) + " < 2-1"
WEND
CLOSE


FileIn$ = "Movies-2-2.txt"
Print "Reading: "; FileIn$
OPEN FileIn$ FOR INPUT AS #1
WHILE NOT EOF(1)
  fcnt = fcnt + 1
  LINE INPUT #1, A$(fcnt)
  A$(fcnt) = Left$(A$(fcnt) + Pad$, 40) + " < 2-2"
WEND
CLOSE

Print "read "; fcnt; " entries"
'go$ = Input$(1)

Print"Sorting: "
GOSUB QSORTDIR


Print "Writing: 'ALL.TXT'"
OPEN "All.txt" FOR OUTPUT AS #1

PRINT #1, "Movie List - Run "; DATE$; "  "; Time$
PRINT #1, ""
Cls:
Print Fcnt; " entries"; : print

FOR x = 1 TO fcnt
  Print x, A$(x)
  PRINT #1, x; TAB(8); A$(x)
NEXT x
CLOSE


Print
go$ = input$(1)
Print "end:":sleep
END


'--------------------------------------------------------------------
QSORTDIR:
   Dim Indx As Integer, I As integer, J As Integer, L As Integer
   Dim NumPasReq As Integer
   Dim strJ As string, strL As String

   NumRec = fcnt
   NumPas = 0
   Indx = 1
 
   WHILE Indx <= NumRec
       Indx = Indx + Indx
       Indx = Indx + Indx
       NumPas = NumPas +1     
   WEND

   Indx = (Indx - 1) \ 2
   WHILE Indx     
       NumPas = NumPas + 1
       FOR I = 1 TO NumRec - Indx
           J = I       
           WHILE J > 0
              L = J + Indx
              strJ = A$(J)
              strL = A$(L)

              IF strJ > strL THEN
                 SWAP A$(L), A$(J)
                 J = J - Indx
              ELSE
                 J = 0
              END If
              '
           WEND                                  ' WHILE J>0
       NEXT I                                     ' NEXT record
       '
       Indx = (Indx - 1) \ 2
     WEND
 
     RETURN
'--------------------------------------------------------------------
Last edited by cavelamb on Jan 28, 2019 23:18, edited 1 time in total.
badidea
Posts: 2076
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Ownership?

Postby badidea » Jan 28, 2019 21:09

Same behaviour if you remove the 'sleep' at the end?
UEZ
Posts: 582
Joined: May 05, 2017 19:59
Location: Germany

Re: Ownership?

Postby UEZ » Jan 28, 2019 21:23

UEZ wrote:Are you sure that the compiled exe is not still running in the background?
When you compile the code as GUI but has at the end a Sleep then the program waits do get a key pressed.


;-)
cavelamb
Posts: 25
Joined: Jan 04, 2010 9:03
Location: earth
Contact:

Re: Ownership?

Postby cavelamb » Jan 28, 2019 23:25

Tourist Trap wrote:
cavelamb wrote:Win 7 64 bit
new Freebasic Install

Once my code compiles and creates an EXE file, I run into trouble.
I can not compile again

Can't erase the EXE.
A box comes up saying I need permission to perform this action.

Sometimes it offers "Yes"
Sometime "Try again" - which never works.

When that happens, clicking on the compiled program gets:
Windows cannot access the specified device, path, or file.
You may not have appropriate permissions to access the item.

Hello,
something is unclear to me. Do every programs you compile in fb are in trouble, or just one? Also, where is your program on the disk? Did you try a quickrun in FBIDE for example? Did you try another computer to run your exe on?
And finally, where did you get your fb version?
All of this can influe, as well of course as your antivirus. Personnally I would use quickrun on fbide + -exx option because it's always what I do, I don't see what can be causing what you describe. I would try to change something from the context, like the ide, the directory of execution etc...


I'm using FBedit, for what that's worth.
Could that be a problem?

ALL compiled programs behave this way.
The program will run just fine.
But can't erase it (the exe) and can't overwrite it.

I shut down anti-virus and tried it.
No change

OKAY!
Making more sense now.
The exe is running as a PROCESS instead of application!
What's that about?

FBedit was compiling as Windows Console. THat's correct, isn't it?

But why a process?
the console screen never opens, so it doesn't close (as everybody said)
jj2007
Posts: 1523
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Ownership?

Postby jj2007 » Jan 29, 2019 3:54

cavelamb wrote:FBedit was compiling as Windows Console. THat's correct, isn't it?
Most probably, NO. Check the compiler options for a -s gui.
But why a process?
Because it's not an application: There is no GUI window.

The problem is that you are using a console function, Sleep, in a "wannabe" GUI application that does neither create an own window (RegisterClassEx + CreateWindowEx + message loop + WndProc etc on Windows) nor opens a console window. Sleep waits for a keypress but can't show it to you. There are intelligent IDEs that warn you about it, or compile automagically as a console process. If your IDE can't do that, the easiest solution is to always compile with option -s console.

Return to “Beginners”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 6 guests