[Tutorial] Use CLI to connect to your ZimaOS SAMBA shares on Windows/macOS

SAMBA is the default sharing protocol on ZimaOS. With SMABA, you can access your photos, videos from another phone or computer, so that you can put data in one place and access or share them everywhere.

The specific benefits of SAMBA sharing are listed in this table:

SAMBA USB drives
Data Duplication? No Yes
What devices? Phones, TVs, Computers USB ports equipped
When and where? Any time devices have a network Where USB Plugged
How many devices? Many at the same time One at a time

Today, we will use CLI to connect ZimaOS’ folders on macOS and Windows.

For Mac Users

Open a text editor and copy these codes. We suggest VSCode as the text editor.

#!/bin/bash

# Prompt the user for IP address, username, and password
read -p "Enter IP Address: " IP
read -p "Enter Username: " USERNAME
read -p "Enter Password: " PASSWORD
echo ""

# Build the SMB URL
SMB_URL="smb://$USERNAME:$PASSWORD@$IP"

# Display connection information
echo "Connecting to: $SMB_URL"

# Open the shared path in Finder
open "$SMB_URL"

# Completion message
echo "SMB connection command executed. Check Finder for the result."

Save this to a file named like Connect to ZimaOS.sh.

Open terminal and type bash (do not miss the space). Then, drag the .sh file into the terminal app and press Enter to run the script.

This script will prompt you to input your ZimaOS’ IP address, username and password. Double check your inputs to ensure correctness. After confirmation, press Enter and you will be in your sharing panel.

For macOS users, you can drag the destination folder to the left panel to get quicker access in the future.

For Windows Users

Open Notepad.exe and copy-paste these codes:

@echo off
echo Please enter the following details:
set /p IP=Enter IP Address: 
set /p USERNAME=Enter Username: 
set /p PASSWORD=Enter Password: 

:: Delete previous network drive if exists
net use \\%IP%\ /delete /y

:: Save credentials using cmdkey
cmdkey /add:%IP% /user:%USERNAME% /pass:%PASSWORD%

:: Map the network drive
net use \\%IP%\ /USER:%USERNAME% %PASSWORD% /PERSISTENT:YES

:: Open the network share
start explorer \\%IP%\

:: Pause for a moment to allow explorer to open the folder
timeout /t 2 /nobreak > NUL

:: Refresh the folder window using PowerShell
powershell -Command "
Add-Type -TypeDefinition @'
using System.Runtime.InteropServices;
public class WinAPI {
    [DllImport(\"user32.dll\")]
    public static extern bool SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
}
'@
\$HWND = (Get-Process | Where-Object { \$_.MainWindowTitle -match '%IP%' }).MainWindowHandle
if (\$HWND -ne [IntPtr]::Zero) {
    [WinAPI]::SendMessage(\$HWND, 0x0111, [IntPtr]0x702C, [IntPtr]0)
} else {
    Write-Host \"Window not found.\"
}
"

echo Commands executed successfully.
pause

Save that text file and give it a ‘.bat’ suffix. Now, click to run this script.

This script will prompt you to input your ZimaOS’ IP address, username and password. Double check your inputs to ensure correctness. After confirmation, press Enter and you will be in your sharing panel.

Windows users can right click the destination folder and choose the map network drive so that you can view your folders in This PC panel.

1 Like

This does not work on my Windows 11 PC. After running the .bat I get a bunch of error msgs. It shows an explorer window with my shares and I can access them. I cannot click on the “Network” main directory. Then I loose the connection and I can go back to the last active window.

Messages look like this:


CMDKEY: Credential added successfully.
The command completed successfully.

'Add-Type' is not recognized as an internal or external command,
operable program or batch file.
'using' is not recognized as an internal or external command,
operable program or batch file.
'public' is not recognized as an internal or external command,
operable program or batch file.
'[DllImport' is not recognized as an internal or external command,
operable program or batch file.
'public' is not recognized as an internal or external command,
operable program or batch file.
'}' is not recognized as an internal or external command,
operable program or batch file.
''@' is not recognized as an internal or external command,
operable program or batch file.
'\$HWND' is not recognized as an internal or external command,
operable program or batch file.

What is going on?

Just provide us with a screen record. Thanks.

Sorry for the long delay, other urgent things to do!

Nothing more to show. Before these messages appear the explorer shows all shares.

Try to run this both in the cmd and PowerShell to elimilate the possible limitation from the environment.

Use Notepad.exe to paste and save the code.

Hope you can record the process of your operations to locate possible issues.