In this lesson, we will guide you through the process of setting up the HNG Unity Store as a Windows service. This will allow the store to run automatically on system startup, ensuring it is always available to manage Unity-related store operations. The process involves downloading the required files, extracting them, and creating the necessary scripts to manage the service.
Step 1: Download the Store Front ZIP File
To begin, you need to download the HNG Unity Store Front ZIP file. This file contains all the necessary components to run the store on your Windows machine.
- Visit the official download page or use the provided link from your instructor.
- Click on the Download ZIP button and save the file to a convenient location on your system (e.g.,
C:\Downloads).
Step 2: Extract the ZIP File
After downloading the ZIP file, the next step is to extract its contents.
- Navigate to the folder where you downloaded the ZIP file (e.g.,
C:\Downloads). - Right-click the ZIP file and select Extract All.
- Choose a destination for the extracted files. For this tutorial, we will use
C:\HNGUnityStore. - Click Extract to extract the files to the specified location.
You should now have a folder named HNGUnityStore containing the necessary files, including the HNGUnityStore.dll which will be used in the service setup.
Step 3: Creating a Script to Install the Service
To run the HNG Unity Store as a Windows service, we need to create a script that will install the service and configure it to start automatically when the system boots.
- Open Notepad or any text editor of your choice.
- Copy and paste the following script into the editor:
@echo off
REM Service Name
set SERVICE_NAME=HNGUnityStoreREM Path to the executableset EXE_PATH=”C:\path\to\dotnet.exe”
set APP_PATH=”C:\path\to\HNGUnityStore.dll”
REM Install the service
sc create %SERVICE_NAME% binPath= “%EXE_PATH% %APP_PATH%” start= auto DisplayName= “HNG Unity Store Service”
REM Set the description (optional)
sc description %SERVICE_NAME% “HNG Unity Store Service for managing Unity-related store operations.”
REM Start the service
sc start %SERVICE_NAME%
echo Service %SERVICE_NAME% installed and started successfully.
pause
Important Notes:
- Replace
C:\path\to\dotnet.exewith the actual path to thedotnet.exeon your system. For example, it could be something likeC:\Program Files\dotnet\dotnet.exe. - Replace
C:\path\to\HNGUnityStore.dllwith the path to theHNGUnityStore.dllfile you extracted earlier (e.g.,C:\HNGUnityStore\HNGUnityStore.dll).
- Save the file as
InstallService.batin the same directory where you extracted the store files (e.g.,C:\HNGUnityStore).
Step 4: Running the Script to Install the Service
Now that we have the installation script ready, it’s time to run it and install the HNG Unity Store as a Windows service.
- Open the Command Prompt as an administrator:
- Press Windows + X and select Command Prompt (Admin) or Windows Terminal (Admin).
- Navigate to the folder where you saved the
InstallService.batfile. You can do this by typing:cd C:\HNGUnityStore
- Run the script by typing:
InstallService.bat
The script will execute the following steps:
- Create the HNG Unity Store service.
- Set it to start automatically on system startup.
- Provide a description for the service.
- Start the service immediately after installation.
You should see a message indicating that the service was installed and started successfully.
Step 5: Verifying the Service Installation
After running the installation script, verify that the service has been installed and is running correctly.
- Open the Services app by typing
services.mscin the Windows search bar. - In the Services window, scroll down to find the HNGUnityStore service.
- Ensure that the status of the service is Running. If it’s not running, you can manually start it by right-clicking the service and selecting Start.
The service is now set up and will automatically run every time the system boots.
Step 6: Creating a Script to Remove the Service
If you ever need to stop and remove the HNG Unity Store service, you can create another script to handle this process.
- Open Notepad or your preferred text editor.
- Copy and paste the following script:
@echo off
REM Service Name
set SERVICE_NAME=HNGUnityStoreREM Stop the servicesc stop %SERVICE_NAME%
REM Delete the service
sc delete %SERVICE_NAME%
echo Service %SERVICE_NAME% stopped and removed successfully.
pause
Save this file as RemoveService.bat in the same folder (C:\HNGUnityStore).
Step 7: Running the Script to Remove the Service
To stop and remove the service:
- Open the Command Prompt as an administrator (same as Step 4).
- Navigate to the folder where you saved the
RemoveService.batfile:cd C:\HNGUnityStore
- Run the script:
RemoveService.bat
This will:
- Stop the HNG Unity Store service.
- Remove it from the list of Windows services.
Once the script finishes, you will see a message confirming that the service was stopped and removed successfully.
Conclusion
By following this lesson, you’ve successfully set up the HNG Unity Store as a Windows service, ensuring it runs automatically at startup and can be easily managed through scripts. You’ve also learned how to stop and remove the service if needed.
This configuration will allow you to manage the Unity store seamlessly on a Windows machine, ensuring it’s always up and running to handle in-game store operations.
