Communiquer avec un script vbs

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Avatar de l’utilisateur
ChaudEf
Messages : 179
Inscription : dim. 27/déc./2015 17:02
Localisation : Strasbourg

Communiquer avec un script vbs

Message par ChaudEf »

Bonsoir, j'utilise un petit script vbs pour creer un point de restauration, et je l'appelle depuis mon programme avec un runprogram.
A l'origine il affiche un message a la fin pour avertir si la creation du point de restauration a reussi ou pas.
Je voudrais qu'il "dise" ca a mon programme directement, et mon programme sache si ca a marche ou pas.
Il y a un moyen de recuperer cette information?

merci

ci joint le script

Code : Tout sélectionner

' Created by: Shawn Brink
' http://www.sevenforums.com
' Tutorial:  http://www.sevenforums.com/tutorials/494-system-restore-point-shortcut.html

Function GetOS    
    Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & ".\root\cimv2")
    Set colOS = objWMI.ExecQuery("Select * from Win32_OperatingSystem")
    For Each objOS in colOS
        If instr(objOS.Caption, "Windows 8") Then
        	GetOS = "Windows 8"
        elseIf instr(objOS.Caption, "Windows 7") Then
        	GetOS = "Windows 7"    
        elseIf instr(objOS.Caption, "Vista") Then
        	GetOS = "Windows Vista"
        elseIf instr(objOS.Caption, "Windows XP") Then
      		GetOS = "Windows XP"
        End If
	Next
End Function

If GetOS = "Windows XP" Then
	CreateSRP
End If

If GetOS = "Windows Vista" Or GetOS = "Windows 7" Then
	If WScript.Arguments.length =0 Then
  		Set objShell = CreateObject("Shell.Application")
		objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1
	Else
  		CreateSRP
  	End If
End If

If GetOS = "Windows 8" Then
	If WScript.Arguments.length =0 Then
  		Set objShell = CreateObject("Shell.Application")
		objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1 
         Else  
               const HKEY_LOCAL_MACHINE = &H80000002
               strComputer = "."
               Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
               strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore"
               strValueName = "SystemRestorePointCreationFrequency"
               oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,0  	
        CreateSRP  
  	End If
End If

Sub CreateSRP
	Set SRP = getobject("winmgmts:\\.\root\default:Systemrestore")
	sDesc = "restauration point"
'	sDesc = InputBox ("Enter a restore point description.", "Create Manual System Restore Point","Manual Restore Point")
	If Trim(sDesc) <> "" Then
		sOut = SRP.createrestorepoint (sDesc, 0, 100)
		If sOut <> 0 Then
	 		WScript.echo "Error " & sOut & ": Unable to create Restore Point."
                else 
                MsgBox "The restore point " & Chr(34) & sDesc & Chr(34) & " was created successfully.", 0, "Create Manual System Restore Point"
		End If
	End If
End Sub

Windows 10 x64 -- Purebasic 5.70 LTS x86