Jump to content

Make a folder in System32


Recommended Posts

I have a bunch of computers receiving an error that can be fixed by following the instructions here.

This is my first script and it is not working can someone please tell me what I am doing wrong?

 

#RequireAdmin
#include <MsgBoxConstants.au3>

Func ESENTFix()
Local $sFilePath = @SystemDir & "\config\systemprofile\AppData\Local\TileDataLayer\Database"

 ; If the directory exists the don't continue.
    If FileExists($sFilePath) Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred. The directory already exists.")
        Return False
    EndIf

ShellExecute(@SystemDir)

    ; Create the directory.
    DirCreate($sFilePath)

    ; Display a message of the directory creation.
    MsgBox($MB_SYSTEMMODAL, "", "The directory has been created.")

    EndFunc ;--> ESENTFix

Basically I used the help file for DirCreate and tried to change the contents to match what I am trying to do. I do not get an error message and nothing is created. It was suggested to add the #RequireAdmin to the start in a chat room but it didn't help and I am not sure I need it or not. I have compiled it two or three times and still doesn't work as x86 or x64.

Thank you

Link to comment
Share on other sites

 

image.thumb.png.be7ed37b56ee5c6d8dc10b056edc2939.png

#RequireAdmin
#include <MsgBoxConstants.au3>

ESSENTFix()

Func ESENTFix()
Local $sFilePath = @WindowsDir & "\System32\config\systemprofile\AppData\Local\TileDataLayer\Database"

 ; If the directory exists the don't continue.
    If FileExists($sFilePath) Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred. The directory already exists.")
        Return False
    EndIf

    ; Create the directory.
    DirCreate($sFilePath)

    ; Display a message of the directory creation.
    MsgBox($MB_SYSTEMMODAL, "", "The directory has been created.")

    EndFunc ;--> ESENTFix

Changed to the above it says the folders were created but as the picture above they are not made.

Also thank you for the help. :)

 

 

 

Link to comment
Share on other sites

1 hour ago, The_Seeker said:

This is my first script and it is not working...

Is this really your complete script? Regardless of errors within, you don't even start the function. Right now, the script doesn't do anything at all ;).

EDIT : Okay, I was a few seconds late. The function is now called.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

9 minutes ago, The_Seeker said:

Changed to the above it says the folders were created ...

You have to check the return value of DirCreate, e.g. :

Local $iResult
    $iResult = DirCreate($sFilePath)
    ; Display a message of the directory creation.
    MsgBox($MB_SYSTEMMODAL, "Create directory : ", "Result = " & $iResult)

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

9 hours ago, The_Seeker said:

Would it be possible for you to show me where to put that in the script or what it is replacing?

Here is a script with additional DEBUG info (can be removed later). As basis I used the last version posted by you. This may not solve your problem, but you will at least get feedback from the script. System folders can be awkward anyway.

#include <MsgBoxConstants.au3>

#RequireAdmin

If _ESENTFix() Then
    ConsoleWrite("> @@DEBUG >>> _ESENTFix = True" & @CRLF)
Else
    ConsoleWrite("! @@DEBUG >>> _ESENTFix = False" & @CRLF)
EndIf


Func _ESENTFix()
    Local $sFilePath = @WindowsDir & "\System32\config\systemprofile\AppData\Local\TileDataLayer\Database"
    Local $iRet

    ConsoleWrite("> @@DEBUG >>> $sFilePath = " & $sFilePath & @CRLF)

    ; If the directory exists then don't continue :
    If FileExists($sFilePath) Then
        ConsoleWrite("! @@DEBUG >>> FileExists = ERROR : The directory already exists" & @CRLF)
        MsgBox($MB_SYSTEMMODAL, "FileExists :", "ERROR : The directory already exists")

        Return False
    Else
        ConsoleWrite("+ @@DEBUG >>> FileExists = OK : The directory does not exists" & @CRLF)
    EndIf

    ; Create the directory. ==> Return Values : 1=Success ; 0=Failure)
    $iRet = DirCreate($sFilePath)
    ; Display a message of the directory creation.
    If $iRet Then
        ConsoleWrite("+ @@DEBUG >>> DirCreate = OK : The directory has been created" & @CRLF)
        MsgBox($MB_SYSTEMMODAL, "DirCreate :", "OK : The directory has been created")
    Else
        ConsoleWrite("+ @@DEBUG >>> DirCreate = ERROR : Creating the directory" & @CRLF)
        MsgBox($MB_SYSTEMMODAL, "DirCreate :", "ERROR : Creating the directory")

        Return False
    EndIf

    Return True
EndFunc ;--> _ESENTFix

 

Edited by Musashi
typo

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Playing with system32 is always tricky especially on x64 computers running 32bits applications.  Make sure you understand folder redirection and then set the appropriate value to  :

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection (False)

 

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