CREATE TABLE [dbo].[_GPOInstallations]
(id] [int] IDENTITY (1, 1) NOT NULL ,
[machine] [varchar] (50) NOT NULL ,
[username] [varchar] (50) NOT NULL ,
[product] [varchar] (50) NOT NULL ,
[version] [varchar] (50) NOT NULL ,
[started] [datetime] NULL ,
[finished] [datetime] NULL ,
[commited] [bit] NULL ,
[rolledback] [bit] NULL ,
[ResultingState] [tinyint] NULL
)
Function dbRegStart()
On Error Resume Next
If Session.Property("REMOVE") = "ALL" Then
State = 0
Else
State = 1
End If
Set cn = CreateObject("ADODB.Connection")
cn.open "Provider=SQLOLEDB;Integrated Security=SSPI;Initial Catalog=MYDB;Data Source=MYSERVER"
ProductName = Session.Property("ProductName")
ProductVersion = Session.Property("ProductVersion")
Set rs = cn.execute("insert into _GPOInstallations(product,version,Started, ResultingState) select '" & ProductName & "','" & ProductVersion & "',getdate(), " & state & " ; select scope_identity()")
Set rs=rs.nextrecordset
NewId=cstr(rs(0))
rs.close
cn.close
Set cn=Nothing
Session.Property("DBNewID") = NewId
Session.Property("DBRegCommit") = NewId
Session.Property("DBRegRollback") = NewId
End Function
Function DBRegCommit()
On Error Resume Next
NewId = Session.Property("CustomActionData")
If IsNumeric(NewId) Then
Set cn=createobject("adodb.connection")
cn.open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=MYDB;Data Source=MYSERVER"
cn.execute "update _GPOInstallations set Finished=getdate(), commited=1 where id=" & newid
cn.close
Set cn=Nothing
End If
End Function
Function DBRegRollback()
On Error Resume Next
NewId = Session.Property("CustomActionData")
If IsNumeric(NewId) Then
Set cn=createobject("adodb.connection")
cn.open "Provider=SQLOLEDB;Integrated Security=SSPI;Initial Catalog=MYDB;DataSource=MYSERVER"
If Session.Property("REMOVE") = "ALL" Then
State = 0
Else
State = 1
End If
cn.execute "update _GPOInstallations set Finished=getdate(), rolledback=1 where id=" & Session.Property("CustomActionData")
cn.close
Set cn=Nothing
End If
End Function
Select machine from _gpoinstallations
Where
Product = 'MyProduct' and version = '1.0.0'
And isnull(rolledback,0) = 0
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (1)
Commented:
Thanks.
Regards,
Rob.