How to share drive on network using windows cmd or powershell #cmd #windows #powershell #cmdcommands

 #cmd #windows #powershell #cmdcommands

To enable file and printer sharing on a Windows network using the Command Prompt, you can follow these steps:


### 1. **Enable Network Discovery**

Network discovery allows your PC to find other devices on the network. To enable it via CMD:


```cmd

netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes

```


---


### 2. **Enable File and Printer Sharing**

To allow file and printer sharing on the network:


```cmd

netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes

```


---


### 3. **Set Sharing Options for a Folder**

You can share a specific folder using the `net share` command:


1. Share a folder:

   ```cmd

   net share Sharename=Path /grant:everyone,full

   ```

   - Replace `Sharename` with the name you want for the shared folder.

   - Replace `Path` with the full path to the folder you want to share (e.g., `C:\SharedFolder`).


   Example:

   ```cmd

   net share SharedDocs=C:\SharedDocs /grant:everyone,full

   ```


2. Remove sharing for a folder:

   ```cmd

   net share Sharename /delete

   ```


---


### 4. **Verify Network Settings**

Ensure your network profile is set to "Private" to enable sharing:


```cmd

PowerShell

Set-NetConnectionProfile -NetworkCategory Private

```


---


### 5. **Restart Network Service (Optional)**

Restart the networking service if you face issues:


```cmd

net stop "Server" && net start "Server"

```


These commands will enable sharing and make your PC discoverable to others on the network. Let me know if you need further help!

To share a drive over a network in Windows 10 using the Command Prompt, follow these steps:


---


### 1. **Open Command Prompt as Administrator**

   - Press `Win + S`, type `cmd`, and select **Run as administrator**.


---


### 2. **Share the Drive Using `net share`**

   Use the `net share` command to share the drive. Replace placeholders with your details:


   ```cmd

   net share ShareName=DrivePath /grant:User,permissions

   ```


   - **`ShareName`**: Name you want for the shared drive (e.g., `SharedDrive`).

   - **`DrivePath`**: Full path of the drive to share (e.g., `D:\`).

   - **`User`**: Name of the user to grant permissions to (e.g., `Everyone` for all users).

   - **`permissions`**: Access permissions (e.g., `FULL` for full access or `READ` for read-only).


   **Example**:

   ```cmd

   net share SharedDrive=D:\ /grant:Everyone,FULL

   ```


---


### 3. **Verify the Shared Drive**

   - To check if the drive was successfully shared, use:

     ```cmd

     net share

     ```

   - This will list all shared resources.


---


### 4. **Access Shared Drive Over the Network**

   - On another computer in the network, press `Win + R`, type:

     ```cmd

     \\YourComputerName\ShareName

     ```

   - Replace `YourComputerName` with the hostname or IP address of the computer sharing the drive and `ShareName` with the name given during sharing.


---


### 5. **Stop Sharing the Drive**

   To stop sharing, use:

   ```cmd

   net share ShareName /delete

   ```


   **Example**:

   ```cmd

   net share SharedDrive /delete

   ```


This approach is simple and does not require GUI interaction. Let me know if you need help with specific scenarios!

Comments