Jump to content

fileexists("C:\Documents and Settings") ??


LoWang
 Share

Recommended Posts

Hello somebody explain me this please

#AutoIt3Wrapper_Change2CUI=y
$l=FileExists("C:\Documents and Settings")
consolewrite("fileexist:"&$l&@crlf)
runwait('cmd.exe /c dir "C:\Documents and Settings"')

results into

fileexist:1
 Volume in drive C has no label.
 Volume Serial Number is CA10-DDF4

 Directory of C:\Documents and Settings

File Not Found

It's a windows server 2008 and the folder is NOT there. The same happens when I run this script on a windows 7 machine.

Link to comment
Share on other sites

The directory "C:\Documents and Settings" exists on my Windows 7 machine.
As you have read permission on C: function fileexists can find this directory.

With "Dir" you try to read the content of this directory. That fails because you do not have permission to read the content of the directory.
At least that's how it is here.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Are you sure that folder exists on your Win7? I have a feeling it may be just a NTFS link for backwards compatibility with apps which may not be using proper system variables. You can see it as a different icon in Total Commander. And my script has rights because I run it in an elevated command promtp.

What is the most reliable way to detect if the system is W2K8 or W2K3? Checking @OSArch macro? Or maybe checking for existence of c:\users folder...?

Edited by LoWang
Link to comment
Share on other sites

Yes, I'm sure. I checked it with Windows Explorer (removed the limitation to not display protected system files).

Or open a cmd window and try: dir C:\ /A:HS

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Use

ConsoleWrite(@OSVersion & @CRLF)

to retrieve information about the system you use.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

_WinAPI_GetProfilesDirectory is included in the latest version of AutoIt (3.3.14.2).
Before you upgrade: But be aware that since 3.3.8.1 there have been a lot of script breaking changes!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You can also use something like this :

MsgBox(0, "", _ProfilesDir() )

Func _ProfilesDir()
    $iPreviousMode = Opt("ExpandEnvStrings", 1)
    $sRegVal = RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", "ProfilesDirectory")
    $sProfilesDir = $sRegVal
    Opt("ExpandEnvStrings", $iPreviousMode)
    Return $sProfilesDir
EndFunc

 

Link to comment
Share on other sites

what is the purpose of this?

$iPreviousMode = Opt("ExpandEnvStrings", 1)

BTW I am not sure this line works as you think it does :-] If you can read the current Opt. This already sets it to 1 doesn't it?

Edited by LoWang
Link to comment
Share on other sites

The line sets the option to "1" BUT returns the status BEFORE it sets it to "1".

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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