Jump to content

Function definition files can be deleted, but can not create the same file?


i2i8
 Share

Recommended Posts

Trouble you again.

My Script:

#include <File.au3>L
Local $setFiles[13]
$setFiles[0] = @ScriptDir & "\idsdk.dll"
$setFiles[1] = @ScriptDir & "\sdk.dll"
$setFiles[2] = @ScriptDir & "\ProcSafe.exe"
$setFiles[3] = @ScriptDir & "\Safe.*"
$setFiles[4] = @ScriptDir & "\BHOEx.dll"
$setFiles[5] = @ScriptDir & "\CServer.dll"
$setFiles[6] = @ScriptDir & "\vDiskBus.inf"
$setFiles[7] = @ScriptDir & "\vDiskBus.sys"
$setFiles[8] = @ScriptDir & "\nti.exe"
$setFiles[9] = @ScriptDir & "\GdiPlus.dll"
$setFiles[10] = @ScriptDir & "\data\ClientBrand.ini"
$setFiles[11] = @ScriptDir & "\data\GameSearchCfg.ini"
$setFiles[12] = @ScriptDir & "\processSafe\ProcessSafe.ini"
For $i = 0 To UBound($setFiles) -1
    If FileExists($setFiles[$i]) Then
    FileDelete($setFiles[$i])
;   _FileCreate($setFiles[$i])
EndIf
Next

Comment the line does not work.Why?

Edited by i2i8
Link to comment
Share on other sites

What's the value of @error after _FileCreate?

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

Is it possible that it's not creating the files because they don't exist already? Your if statement only runs what's inside of it if the files already exist.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

OK. Can you try this version?

I think the error was caused by your usage of UBound. Not specifying the second parameter only returns the number of dimensions of the array. But you need the number of elements in the first dimension.

#include <File.au3>
Local $setFiles[13]
$setFiles[0] = @ScriptDir & "\idsdk.dll"
$setFiles[1] = @ScriptDir & "\sdk.dll"
$setFiles[2] = @ScriptDir & "\ProcSafe.exe"
$setFiles[3] = @ScriptDir & "\Safe.*"
$setFiles[4] = @ScriptDir & "\BHOEx.dll"
$setFiles[5] = @ScriptDir & "\CServer.dll"
$setFiles[6] = @ScriptDir & "\vDiskBus.inf"
$setFiles[7] = @ScriptDir & "\vDiskBus.sys"
$setFiles[8] = @ScriptDir & "\nti.exe"
$setFiles[9] = @ScriptDir & "\GdiPlus.dll"
$setFiles[10] = @ScriptDir & "\data\ClientBrand.ini"
$setFiles[11] = @ScriptDir & "\data\GameSearchCfg.ini"
$setFiles[12] = @ScriptDir & "\processSafe\ProcessSafe.ini"
For $i = 0 To UBound($setFiles, 1) -1
    If FileExists($setFiles[$i]) Then
        $iReturn = FileDelete($setFiles[$i])
        ConsoleWrite("Deleting file " & $setFiles[$i] & " returned " & $iReturn)
        _FileCreate($setFiles[$i])
        ConsoleWrite("Creating file " & $setFiles[$i] & " returned " & @error)
    EndIf
Next

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

 

OK. Can you try this version?

I think the error was caused by your usage of UBound. Not specifying the second parameter only returns the number of dimensions of the array. But you need the number of elements in the first dimension.

#include <File.au3>
Local $setFiles[13]
$setFiles[0] = @ScriptDir & "\idsdk.dll"
$setFiles[1] = @ScriptDir & "\sdk.dll"
$setFiles[2] = @ScriptDir & "\ProcSafe.exe"
$setFiles[3] = @ScriptDir & "\Safe.*"
$setFiles[4] = @ScriptDir & "\BHOEx.dll"
$setFiles[5] = @ScriptDir & "\CServer.dll"
$setFiles[6] = @ScriptDir & "\vDiskBus.inf"
$setFiles[7] = @ScriptDir & "\vDiskBus.sys"
$setFiles[8] = @ScriptDir & "\nti.exe"
$setFiles[9] = @ScriptDir & "\GdiPlus.dll"
$setFiles[10] = @ScriptDir & "\data\ClientBrand.ini"
$setFiles[11] = @ScriptDir & "\data\GameSearchCfg.ini"
$setFiles[12] = @ScriptDir & "\processSafe\ProcessSafe.ini"
For $i = 0 To UBound($setFiles, 1) -1
    If FileExists($setFiles[$i]) Then
        $iReturn = FileDelete($setFiles[$i])
        ConsoleWrite("Deleting file " & $setFiles[$i] & " returned " & $iReturn)
        _FileCreate($setFiles[$i])
        ConsoleWrite("Creating file " & $setFiles[$i] & " returned " & @error)
    EndIf
Next

 

Can be deleted, but can not create the same file.

They are not running, just unzip the files out of the winrar.

Link to comment
Share on other sites

Please, give us more information! "Not running" doesn't help very much!

What is the output on the SciTE console pane?

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

Please, give us more information! "Not running" doesn't help very much!

What is the output on the SciTE console pane?

Thank you Water !

For example, can be.

For $i = 0 To UBound($setFiles) -1
    If FileExists($setFiles[$i]) Then
    FileDelete($setFiles[$i])
    Else
    _FileCreate($setFiles[$i])
EndIf
Next

Is there a better way?

Edited by i2i8
Link to comment
Share on other sites

Did you run the script I posted above in post #5?

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

Ok, that's my very last try! What do you get on the SciTE output pane?

I have added ConsoleWrite statements to my script so it gives us detailed information what happens.

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

Ok, that's my very last try! What do you get on the SciTE output pane?

I have added ConsoleWrite statements to my script so it gives us detailed information what happens.

+> ============================================

> Run AU3Check (3.3.10.2) began directory: D: autoit3

+> 22:26:48 AU3Check completed

: 0

> Run: (3.3.10.2): D: autoit3 autoit3_x64.exe "C: Client Client.au3"

+> 22:26:48 AutoIt3.exe completed: [code]: 0

+> 22:26:49 ACNWrapper completed ..

> Exit code: 0 Running time: 1.109 seconds

Link to comment
Share on other sites

I'm Sorry,Water,I know

Deleting file C:\Client\BHOEx.dll returned 1Creating file C:\Client\BHOEx.dll returned 0Deleting file C:\Client\GdiPlus.dll returned 1Creating file C:\Client\GdiPlus.dll returned 0Deleting file C:\Client\data\ClientBrand.ini returned 1Creating file C:\Client\data\ClientBrand.ini returned 0Deleting file C:\Client\data\GameSearchCfg.ini returned 1Creating file C:\Client\data\GameSearchCfg.ini returned 0+>22:52:07 AutoIt3.exe Completed: [CODE]: 0
Link to comment
Share on other sites

This tells us that 4 files already existed, have successfully been deleted and created.

So you should find this 4 empty files in your folder.

For the files that didn't exist your script does nothing.

Deleting file C:ClientBHOEx.dll returned 1
Creating file C:ClientBHOEx.dll returned 0

Deleting file C:ClientGdiPlus.dll returned 1
Creating file C:ClientGdiPlus.dll returned 0

Deleting file C:ClientdataClientBrand.ini returned 1
Creating file C:ClientdataClientBrand.ini returned 0

Deleting file C:ClientdataGameSearchCfg.ini returned 1
Creating file C:ClientdataGameSearchCfg.ini returned 0

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

This tells us that 4 files already existed, have successfully been deleted and created.

So you should find this 4 empty files in your folder.

For the files that didn't exist your script does nothing.

Well, then, I know how to do it. So thank you, thank you, thank you very much

Link to comment
Share on other sites

:)

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...