cyberiadmin
asked on
ASP.net extract 7zip
Hello,
How can i create a ASP.net 2.0 script that does the following in order.
1) shutdown a services
2) deletes a folder and all sub content
3) extracts a 7zip archive
4) start up a services
Thanks
How can i create a ASP.net 2.0 script that does the following in order.
1) shutdown a services
2) deletes a folder and all sub content
3) extracts a 7zip archive
4) start up a services
Thanks
okay I know you said asp.net 2.0 script. I am not sure what you mean by that. I assume some dotnet code? So either vb.net or c#. Considering your last couple of questions was vbscript related, I assume you will be content with vb.net
so to continue
2) try the code here http://www.java2s.com/Tutorial/VB/0160__Collections/Deleteadirectorycontainingfilesandsubdirectories.htm
Imports System.IO
Public Class Tester
Public Shared Sub Main
Try
System.IO.Directory.Delete ("c:\a", True)
Catch ex As Exception
Console.WriteLine(ex.ToStr ing)
Finally
Beep()
End Try
End Sub
End Class
so to continue
2) try the code here http://www.java2s.com/Tutorial/VB/0160__Collections/Deleteadirectorycontainingfilesandsubdirectories.htm
Imports System.IO
Public Class Tester
Public Shared Sub Main
Try
System.IO.Directory.Delete
Catch ex As Exception
Console.WriteLine(ex.ToStr
Finally
Beep()
End Try
End Sub
End Class
ASKER
Found out how to do part 1 and part 4 but thanks for the info for part 1 as i will need to still use this else where in the coding.
dim service as New TCAdminSDK.Objects.Service
service.ServiceId="TCXXXXX XXXX"
If service.Find() Then
service.Stop()
service.Start()
End If
dim service as New TCAdminSDK.Objects.Service
service.ServiceId="TCXXXXX
If service.Find() Then
service.Stop()
service.Start()
End If
ASKER
http://en.wikipedia.org/wiki/ASP.NET
I have added an exmaple script created by LFA, that just list the server ip and port of the login user game server.
I have added an exmaple script created by LFA, that just list the server ip and port of the login user game server.
<%@ Page LANGUAGE="VB" %>
<%@ Register TagPrefix="cc1" Namespace="TCAdminSDK.Web.UI" Assembly="TCAdminSDK" %>
<html>
<head>
<title><%=TCAdminSDK.Web.Templates.GetCustomTitle() %> - Custom Page</title>
<SCRIPT LANGUAGE="VB" RUNAT="server">
Private _SelectedService As TCAdminSDK.Objects.Service
Public ReadOnly Property SelectedService() As TCAdminSDK.Objects.Service
Get
If _SelectedService Is Nothing Then
_SelectedService = New TCAdminSDK.Objects.Service
_SelectedService.ServiceID = Request.QueryString("serviceid")
If _SelectedService.Find() Then
' ''''''''''''''''''' '
'Basic security check '
' ''''''''''''''''''' '
Select Case TCAdminSDK.Web.Session.CurrentUserType
Case TCAdminSDK.Objects.UserType.Admin, TCAdminSDK.Objects.UserType.SubAdmin
' ''''''''''''''''''''''''''''''''''''''' '
'Admin and subadmin always has permission '
' ''''''''''''''''''''''''''''''''''''''' '
Case TCAdminSDK.Objects.UserType.User
' ''''''''''''''''''''''''''''''''''''''''''' '
'Current user should be the game server owner '
' ''''''''''''''''''''''''''''''''''''''''''' '
If Not _SelectedService.UserID = TCAdminSDK.Web.Session.CurrentUser Then
TCAdminSDK.Web.Util.RedirectToHome()
End If
Case TCAdminSDK.Objects.UserType.SubUser
' ''''''''''''''''''''''''''''''''''''''''''''''''' '
'Current user owner should be the game server owner '
' ''''''''''''''''''''''''''''''''''''''''''''''''' '
If Not _SelectedService.UserID = TCAdminSDK.Web.Session.CurrentUserParentAccount Then
TCAdminSDK.Web.Util.RedirectToHome()
End If
End Select
End If
End If
Return _SelectedService
End Get
End Property
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'Redirect to login page if not authenticated
If Not TCAdminSDK.Web.Session.IsAuthenticated Then
Response.Redirect(String.Format("Login.aspx?returnto={0}", Request.RawUrl))
End If
End Sub
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' '''''''''''''''''''''''''''''''''''''''' '
'You can add code for the page load event. '
' '''''''''''''''''''''''''''''''''''''''' '
End Sub
</SCRIPT>
</head>
<body>
<!-- #Include virtual="header.aspx" -->
<!-- --------------------------------- -->
<!-- Create the breadcrumb manually :( -->
<!-- --------------------------------- -->
<div style="width: 100%; text-align: center;" id="NavigationPanel">
<table cellspacing="0" cellpadding="0" border="0" align="center" class="navigation_menu"><tr>
<td style="width: 90%;" class="description_labels_small"><a href="admin_home.aspx"><%=iif(TCAdminSDK.Web.Session.CurrentUserType=TCAdminSDK.Objects.UserType.Admin, "Admin", "User") %> Home</a> > <a href="services.aspx">Game Servers</a> > <a href="<%=String.Format("service_home.aspx?serviceid={0}&svc_short_desc={1}",Me.SelectedService.ServiceId, Me.SelectedService.ShortGameNameAndSlots) %>"><%=Me.SelectedService.ShortGameNameAndSlots %></a> > <%=Me.MenuHeader1.Text %> </td>
<td align="right" class="description_labels_small">
<span>[</span>
<a href="login.aspx?action=LogOff">Log Out</a>
<span>]</span></td>
</tr>
</table>
</div>
<!-- ----------------- -->
<!-- End of breadcrumb -->
<!-- ----------------- -->
<cc1:menuheader id="MenuHeader1" runat="server" Width="695px" Text="Custom Page"></cc1:menuheader>
<!-- -------------------------- -->
<!-- Your custom code Goes Here -->
<!-- -------------------------- -->
<br/>Game Server Ip: <%=Me.SelectedService.ServerIP %><br/>
Game Server Port: <%=Me.SelectedService.ServerPort %><br/>
<!-- ------------------ -->
<!-- End of custom code -->
<!-- ------------------ -->
<!-- #Include virtual="footer.aspx" -->
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ok, just saw your posts
its just plain old vb.net. So the code posted should work.
You said you did 1 and 4. I guess they go hand in hand. The code I have differs from yours somewhat.
its just plain old vb.net. So the code posted should work.
You said you did 1 and 4. I guess they go hand in hand. The code I have differs from yours somewhat.
Now I'm off to bed. I will respond to any questions you have tomorrow (later today lol)
ASKER
Thanks, this will help be start off. I will continue looking into this if i do have any more questions about this, hope people do not mind me asking.
With regards to shutting down a service, you can make use of the ServiceController class
You need to add the namespace System.ServiceProcess (may need to asdd reference to it)
then find the name of your service (can be found in registry under hklm/SYSTEM/CurrentControl
Dim controller As New ServiceController
controller.MachineName = "."
controller.ServiceName = "Tomcat5"
controller.Stop()
controller = Nothing
the above example shuts down tomcat v5 service