Script to refresh Windows 8 (VBScript)

Introduction

This VBScript shows how to create custom refresh image.

Scenarios

Windows Refresh lets users use Windows with a clean slate while also maintaining apps, data, Windows settings, and user profile.

Step 1: On the Start page, type cmd. Press and hold or right-click Command Prompt, and then tap or click Run as administrator.

Step 2: Run this VBScript together with cscript in the Windows Command Console. Type the path of the script at the command prompt.

Step 3: The Windows Console displays the following prompt message:
 

Step 4: When the script runs successfully, you will receive a message as shown in the following figure.
 

Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.

VB Script
Edit|Remove
Option Explicit 
  
Dim objShell 
Set objShell = WScript.CreateObject("WScript.Shell") 
  
Dim strPath,objExecObject 
strPath = InputBox("Please ype the path of custom refresh image you want to save:") 
  
'call recimg.exe to create custom imageSet objExecObject = objShell.Exec("recimg /createimage " & strPath) 
Do  
    WScript.StdOut.WriteLine(objExecObject.StdOut.ReadLine()) 
LoopWhileNot objExecObject.StdOut.AtEndOfStream 
  
WScript.StdOut.WriteLine(objExecObject.StdOut.ReadAll)

Prerequisite

Windows 8