Windows 10: Need to create batch file for "net share" command

  1.    2 Weeks Ago #1

    Need to create batch file for "net share" command


    I created a simple command from powershell that maps a drive for me using the "net share" command (see below). However, i want to turn this in to a batch file so I do not have to type it every time. When I name it filename.bat and try to run it, I get a

    system error 5 has occured, access denied

    I assume I have to make this a powershell script. My question is, if I cant run it as a batch file, how do I run this as a powershell script so I only have to click on it to run it?

    *I am extremely new to powershell

    Thank you

    net share myshare=z:\ /grant:user,full /users:1
      My ComputerSystem Spec

  2.    2 Weeks Ago #2

    You have to run that command with Administrator privileges. Right-click the batch file and click Run as administrator.
      My ComputerSystem Spec

  3.    2 Weeks Ago #3

    eeps24 said: View Post
    I created a simple command from powershell that maps a drive for me using the "net share" command (see below). However, i want to turn this in to a batch file so I do not have to type it every time. When I name it filename.bat and try to run it, I get a

    system error 5 has occured, access denied

    I assume I have to make this a powershell script. My question is, if I cant run it as a batch file, how do I run this as a powershell script so I only have to click on it to run it?

    *I am extremely new to powershell

    Thank you

    net share myshare=z:\ /grant:user,full /users:1

    You are not mapping a drive you are configuring share options for Z: drive.

    Mapping a drive to a network share assigns that share a drive letter so that itís easier to work with.

    To map a network drive, type the following command and then hit Enter:
    Code:
    net use x: \\computer name\sharename /user username password
    

    In order to make the connection to the shared folder permanent, you need to add the /P parameter. This will ensure the drive will remain even after a restart. In some versions of Windows, you may have to use /PERSISTENT instead of /P.
    Code:
    net use x: \\computer name\sharename /P:Yes
    You can delete a mapped network drive using the command prompt by typing in the command below.

    Code:
    net use x: /delete
    To delete all mapped network drives by executing below command.

    Code:
    net use * /delete
      My ComputerSystem Spec


 

Related Threads
Hi, just a quick request. Does anyone know how to create a shortcut that I can open that will run the "Undo" command? For example: Suppose you have File Explorer open and delete a file from a folder. You can right click in that folder and click...
After the creator's update they removed the Open command prompt under file in the file explorer. Is there a way to add it back?
Hi guys, Is there a reg/batch script or group policy to turn off this annoying screen in Windows 10? 71799 I know it can be disabled somewehre in IE options but I need it to be a a script or something.
When I was using Windows 7 Pro, my NAS shares were showing in the Network area of the File Manger. But, I no longer see the shares in Windows 10. I can map the shares using the Map Network Drive. That works, but I need to be able to access these...
When I click on a folder to share it, it gives me the usual homegroup options. However, there is another option now and I don't know what it is. It's a string of 20 numbers and letters. See the attached picture for reference. Thanks
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:24.
Find Us