Script not working since upgrade to V7


Author
Message
fireplex
fireplex
New Member
New Member (8 reputation)New Member (8 reputation)New Member (8 reputation)New Member (8 reputation)New Member (8 reputation)New Member (8 reputation)New Member (8 reputation)New Member (8 reputation)New Member (8 reputation)
Group: Forum Members
Posts: 5, Visits: 12
Hello,

I recently upgraded to Macrium V7 from V6 and note one of my folder backups no longer works, its a VBS.

I notice notepad is running via taskmanager but no window for it appears and it does not appear to open my "usbbackup" text file like it did before ?

Any ideas ?

Thanks.


'******************************************************************************
'*
'*
'* Module Name:  C Drive to USB.vbs
'*
'* Abstract:   This is a template VB Script file generated by Reflect v6
'*      Modify to add your own functionality if required
'*
'*
'******************************************************************************

OPTION EXPLICIT

' call the main function
Call VBMain()


'******************************************************************************
'* Sub:  VBMain
'*
'* Purpose: This is main function to start execution
'*
'* Input: None
'*
'* Output: None
'*
'******************************************************************************
Sub VBMain()
Dim objShell
Dim ExitCode

' Elevate this script for Admin privileges in Vista
Elevate

Set objShell = WScript.CreateObject("WScript.Shell")

' Run program before backup
objShell.Run """C:\Windows\System32\notepad.exe"" usbbackup", 1, true

' Do the backup
ExitCode = Backup ("""C:\program files\macrium\reflect\Reflect.exe"" -e -w <BACKUP_TYPE> ""C:\Users\Simon\Documents\Reflect\C Drive to USB.xml"" -g")

' Run program after backup
objShell.Run """C:\Windows\System32\notepad.exe"" usbend", 1, true

' done
Set objShell = nothing
wscript.quit(ExitCode)
End Sub


'******************************************************************************
'* Function: Backup
'*
'* Purpose: Calls Reflect.exe passing an XML BDF as a parameter
'*
'* Input:  strCmdLine Command Line Arguments
'* Output: Exit Code
'*
'******************************************************************************
Function Backup(Byref strCmdLine)
Dim objShell
Dim objExecObject
Dim iReturnCode

strCmdLine = Replace(strCmdLine, "<BACKUP_TYPE>", GetBackupTypeParameter)

' Run the backup or image
Set objShell = WScript.CreateObject("WScript.Shell")
iReturnCode = objShell.Run(strCmdLine, 1, true)

if iReturnCode = 2 then
' Handle XML validation error

elseif iReturnCode = 1 then
' Handle backup error
elseif iReturnCode = 0 then
' Everything OK
end if
Backup = iReturnCode
Set objShell = nothing
End Function


'******************************************************************************
'* Sub:  Elevate
'*
'* Purpose: Elevates this script for Vista UAC.
'*    This means that only one UAC Elevation prompt is displayed and
'*    functions/programs will not fail if they require admin privileges
'*
'* Input: None
'* Output: None
'*
'******************************************************************************
Sub Elevate
Dim ShellApp
Dim objShell
Dim objWshProcessEnv

' Don't elevate if run from Windows Task Scheduler
If WScript.Arguments.Count > 0 Then
If WScript.Arguments.Item(0) = "-s" then
Exit Sub
End If
End If

Set objShell = WScript.CreateObject("WScript.Shell")
Set objWshProcessEnv = objShell.Environment("PROCESS")

If objWshProcessEnv("ELEVATED_APP") <> "True" Then
objWshProcessEnv("ELEVATED_APP") = "True"
Set ShellApp = CreateObject("Shell.Application")
Call ShellApp.ShellExecute("""" & WScript.FullName & """", """" & WScript.ScriptFullName & """" & " " & GetBackupTypeParameter, , "runas")
set ShellApp = nothing
Set objWshProcessEnv = nothing
wscript.quit
End If
Set objWshProcessEnv = nothing
Set objShell = nothing
End Sub

'******************************************************************************
'* Function: GetBackupTypeParameter
'*
'* Purpose: determines the backup type from command line parameter
'*    -full Full backup
'*    -inc Incremental backup
'*    -diff Differential backup
'*
'* Input:  None
'* Output: the parameter
'*
'******************************************************************************
Function GetBackupTypeParameter
Dim i

for i = 0 to Wscript.Arguments.Count - 1
  If Wscript.Arguments(i) = "-full" OR _
   Wscript.Arguments(i) = "-inc" OR _
   Wscript.Arguments(i) = "-diff" Then
   GetBackupTypeParameter = Wscript.Arguments(i)
   Exit Function
  End If
Next

GetBackupTypeParameter = ""

End Function


jphughan
jphughan
Most Valuable Professional
Most Valuable Professional (3.1K reputation)Most Valuable Professional (3.1K reputation)Most Valuable Professional (3.1K reputation)Most Valuable Professional (3.1K reputation)Most Valuable Professional (3.1K reputation)Most Valuable Professional (3.1K reputation)Most Valuable Professional (3.1K reputation)Most Valuable Professional (3.1K reputation)Most Valuable Professional (3.1K reputation)
Group: Forum Members
Posts: 2.2K, Visits: 14K
Might be cleaner to attach your script as a text file next time, and I’m not a VBS person (although every time I read it I’m glad I didn’t get really into scripting until PowerShell! Tongue), but have you tried generating a new VBS file from V7 to verify that works and then copying over any customizations you made to your current script, perhaps in stages, to see what breaks it?
Edited 22 September 2017 2:54 PM by jphughan
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search