Help with FILE()

Post Reply
tsai8839
Posts: 22
Joined: Mon Jul 24, 2006 6:45 am

Help with FILE()

Post by tsai8839 »

I use function FILE() as below, it works fine with windows XP, but it executes MsgStop() function with windows 7. On the other words, the FILE() tell me CMD.EXE file does not exist, but it is exist in fact.

FUNCTION Main()
LOCAL cFile := GetSysDir() + "\CMD.EXE"
IF ! FILE( cFile )
MsgStop( "File does not exist!", "Warning" )
ENDIF
RETURN(NIL)

Any help will be much appreciates.

Andy
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Help with FILE()

Post by anserkk »

Your sample is working fine on my PC running OS Windows 7 - 32 BIT.

Please check the file attribute of the file cmd.exe in your C:\Windows\System32 folder

Regards

Anser
tsai8839
Posts: 22
Joined: Mon Jul 24, 2006 6:45 am

Re: Help with FILE()

Post by tsai8839 »

Thank you Anser, my PC running OS Windows 7 - 64 bit.
Is this cause the problem?

Regards,
Andy
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Help with FILE()

Post by anserkk »

Sorry, as of now I don't have a Windows 7 - 64 bit here. Are you experiencing the same problem with files other than cmd.exe ?
Did you check the output of the function GetSysDir() and is it returning the expected output ?

Regards

Anser
tsai8839
Posts: 22
Joined: Mon Jul 24, 2006 6:45 am

Re: Help with FILE()

Post by tsai8839 »

Anser,

Yes, I have the same problem with files other than cmd.exe, and the function GetSysDir() returns C:\Windows\System32

Regards,
Andy
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Help with FILE()

Post by driessen »

Andi,

Is GetSysDir() returning "C:\Windows\System32" or is it returning "C:\Windows\System32\" ?

In the second case your test would result into "C:\Windows\System32\\cmd.exe", which, of course, doesn't exist.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
tsai8839
Posts: 22
Joined: Mon Jul 24, 2006 6:45 am

Re: Help with FILE()

Post by tsai8839 »

Michel,

The result is "C:\Windows\System32\cmd.exe".

So far as I know, the path is correct, the file is exist. But the result of file() is .F.
I don't know how to fix this problem. Do you have any idea?

Regards,
Andy
Patrizio
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy
Contact:

Re: Help with FILE()

Post by Patrizio »

tsai8839 wrote:Michel,

The result is "C:\Windows\System32\cmd.exe".

So far as I know, the path is correct, the file is exist. But the result of file() is .F.
I don't know how to fix this problem. Do you have any idea?

Regards,
Andy
Andy, do you have correct rights to access to a system dir? Try to execute the test as administrator.
Post Reply