extract 7zip

cyberiadmin used Ask the Experts™

How can i create a 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

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006


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/CurrentControlSet/Services

        Dim controller As New ServiceController

        controller.MachineName = "."
        controller.ServiceName = "Tomcat5"
        controller = Nothing

the above example shuts down tomcat v5 service
Top Expert 2006

okay I know you said 2.0 script. I am not sure what you mean by that. I assume some dotnet code? So either or c#. Considering your last couple of questions was vbscript related, I assume you will be content with

so to continue

2) try the code here

Imports System.IO

Public Class Tester
    Public Shared Sub Main
            System.IO.Directory.Delete("c:\a", True)
        Catch ex As Exception
        End Try

    End Sub

End Class


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
If service.Find() Then
End If
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.



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" %>
    <title><%=TCAdminSDK.Web.Templates.GetCustomTitle() %> - Custom Page</title>

    Private _SelectedService As TCAdminSDK.Objects.Service
    Public ReadOnly Property SelectedService() As TCAdminSDK.Objects.Service
            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
                            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
                            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

   <!-- #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> &gt; <a href="services.aspx">Game Servers</a> &gt; <a href="<%=String.Format("service_home.aspx?serviceid={0}&svc_short_desc={1}",Me.SelectedService.ServiceId, Me.SelectedService.ShortGameNameAndSlots) %>"><%=Me.SelectedService.ShortGameNameAndSlots %></a> &gt; <%=Me.MenuHeader1.Text %> </td>

<td align="right" class="description_labels_small">
<a href="login.aspx?action=LogOff">Log Out</a>



   <!-- ----------------- -->
   <!-- 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" -->

Open in new window

Top Expert 2006
3) Extracting a 7zip file. I would assume it would again be command line driven

Looking at the 7zip website, it suggests HX Dos Extender but didnt make much sense
so found this here

I dont have 7zip but wonder if you could try out some of the examples and post what works here

You could use the old skool vb way and use the shell function to execute this command line for 7zip, it will work but has now a Process object which you can use to execute.

Top Expert 2006

ok, just saw your posts

its just plain old 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.
Top Expert 2006

Now I'm off to bed. I will respond to any questions you have tomorrow (later today lol)


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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial