Jump to content

Automating sfc /scannow to a button


Recommended Posts

Im trying to do as the title says just for automation purposes on a button

But im hitting the 

Windows Resource Protection could not start the repair service. error

so i added the netstart command to make sure the service is started but i still cant get past the error even though the service is started

Case $T4SFCScanButton3
                Local $netstart = RunWait(@ComSpec & " /k " & "net start trustedinstaller", "", @SW_SHOW)
                Sleep(2000)
                RunWait(@ComSpec & " /k " & "sfc /scannow", "", @SW_SHOW)

Anyone know a way to get round this?

Link to comment
Share on other sites

Bet a shiny nickel your button works fine in Safe Mode.  I cant remember if we gave up on sfc at that point, or shortly thereafter.

there it is:

 

To resolve this problem, perform the System File Checker scan in safe mode, and make sure that the PendingDeletes and PendingRenames folders exist under %WinDir%WinSxSTemp.

 

http://support.microsoft.com/en-us/kb/929833

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I was running Admin

Ill test safe mode tommoz at work thx

Just seen a note somewhere doing research about  and AV interfering so i killed mine and it work

More testing to follow

Edited by Chimaera
Link to comment
Share on other sites

So I tested and I have the same issue...

Guess its a system protection thing?

Anyways I gotta run for today but I tried a .bat file and it works(ish) so I thought to try something like this.  

May get you on the right track.

#RequireAdmin
#Include <File.au3>

$pSFC = (@TempDir & "\SFC.bat")

_FileCreate($pSFC)
$fSFC = FileOpen($pSFC, 1)

FileWriteLine($fSFC, "C:\Windows\System32\SFC /ScanNow")
FileWriteLine($fSFC, "/pause")

FileClose($fSFC)
ShellExecute($pSFC)
Edited by ViciousXUSMC
Link to comment
Share on other sites

  • 11 months later...

I realize this is a year old but heres the real answer (works on my win7 box):

If StringInStr(@OSArch, "64") Then
    Run(@ComSpec & " /k " & @WindowsDir & "\Sysnative\sfc /scannow", "", @SW_SHOW)
Else
    Run(@ComSpec & " /k " & @WindowsDir & "\System32\sfc /scannow", "", @SW_SHOW)
EndIf

 

Edited by TouchOdeath
Link to comment
Share on other sites

Its fine, just also wrong.

FileOpenDialog("" , "C:\windows\sysnative\" , "SFC (sfc.exe)")

This by itself, unless you also turn off redirection, would open system32 on an x64 system from a 32bit install of AutoIt.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

4 hours ago, iamtheky said:

Its fine, just also wrong.

FileOpenDialog("" , "C:\windows\sysnative\" , "SFC (sfc.exe)")

This by itself, unless you also turn off redirection, would open system32 on an x64 system from a 32bit install of AutoIt.

You mean 32bit compile not install.  Read:  http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm

I'll supply another answer to this thread since neither of you 'like' my answer.  Again, this works on my x64 system running W7, as far as other OS's, I don't know, test it yourselves.

If StringInStr(@OSArch, "64") Then
    DllCall("kernel32.dll", "boolean", "Wow64EnableWow64FsRedirection", "boolean", 0)
    Run(@ComSpec & " /k " & @WindowsDir & "\System32\sfc /scannow", "", @SW_SHOW)
    DllCall("kernel32.dll", "boolean", "Wow64EnableWow64FsRedirection", "boolean", 1)
Else
    Run(@ComSpec & " /k " & @WindowsDir & "\System32\sfc /scannow", "", @SW_SHOW)
EndIf

 

sysnativefolder.png

Edited by TouchOdeath
Link to comment
Share on other sites

Quote

You mean 32bit compile not install

Unless F5 does a 32bit compile and then runs the script, then i do not mean compile.  If it does, then maybe a directive would handle it as well...

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I'm going to make this crystal clear for everyone.  I'm guessing boththose primary language isn't english.  Heres the skinny on all this:

When installing Autoit, if you have a 32bit system, when installed will always compile your script as a 32bit executable.  So you won't even see the option to install 64bit because you can't run a 64bit program on a 32bit system, you'll get an error.

If you have a 64bit system, when installing Autoit it will ask you if you want 'x64 tools' or 'x86 tools'.  If you pick x64 it will always compile your scripts as a 64bit executable.  If you pick x86, it will always compile your scripts as a 32bit executable.  If you have scite4autoit installed you have the option to specify additional compile parameters to override the 'default' bit compile (regardless if you picked 'x64 tools' or x86 tools').

#AutoIt3Wrapper_UseX64=n

The option above if 'n' will compile a 32bit executable, if 'y' will compile a 64bit executable.  Regardless if you are running a 32bit OS or 64 bit OS.  

On 3/24/2016 at 0:45 PM, TouchOdeath said:

 

If StringInStr(@OSArch, "64") Then
    Run(@ComSpec & " /k " & @WindowsDir & "\Sysnative\sfc /scannow", "", @SW_SHOW)
Else
    Run(@ComSpec & " /k " & @WindowsDir & "\System32\sfc /scannow", "", @SW_SHOW)
EndIf

 

From a 64bit system (Windows Vista+), the above code will always work if compiled from a 32bit executable.  It will always fail if compiled from a 64bit executable.  Regardless if redirection is on or off.  

Edited by TouchOdeath
Link to comment
Share on other sites

thats colorful language, except that the huge boner you have for compilation is blocking your view of scripts that are run WITHOUT being compiled. Or colloquially the 'F5' maneuver when Scite is open.  My understanding is that certain things that relied on compile did not work, because it wasnt compiled.  Unless my English fails me.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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