Question

I am trying to create an .hta application with a vbscript that will open the Windows 8 RecoveryDrive program. The script I have is as follows:

Sub Windows8Recovery
'// Open the Windows 8 / 8.1 default recovery program
Set oShell = CreateObject("Wscript.Shell")
oShell.Run "c:\windows\system32\recoverydrive.exe"
End Sub

Every time I run this I get an error msg: "The system cannot find the file specified."

Help!!!

Was it helpful?

Solution

Finally found the problem. I'm running this on a 64bit OS. Has something to do with windows File System Redirector and how it handles 32bit vs 64bit applications: http://msdn.microsoft.com/en-us/library/aa384187(VS.85). Was able to find a work-around using PowerShell. Here is the working code:

<html>
    <body>
        <a href='#' onclick='Windows8Recovery()'>Win 8 Default Recovery</a>
        <script language="VBScript">
            Sub Windows8Recovery
                Set objShell = CreateObject("Wscript.Shell")
                strRDPath = objShell.ExpandEnvironmentStrings( "%SystemRoot%" ) & "\sysnative\RecoveryDrive.exe"
                Set objShellExec = CreateObject("Shell.Application")
                objShellExec.ShellExecute "powershell.exe", strRDPath, "", "runas", 1               
            End Sub
        </script>
    </body>
</html>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top