1

PC1 is where the script will run, and it is in a domain.
PC2 holds the share folder and it's NOT in any domain.

Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "M:", "\\192.168.0.10\share", administrator, password

What else does the script needs to map the drive?


Edit: This is sort of a duplicate of this question , but i tried to simplify things.

Community
  • 1
  • 1
Cristian Muscalu
  • 9,007
  • 12
  • 44
  • 76
  • So what happens? what is the format of the string in the variable `administrator` – Alex K. Aug 16 '16 at 15:13
  • The username and password for the shared folder are just strings. The PC name for the shared folder is like `PC-10` . I tried `WshNetwork.MapNetwo‌​rkDrive "M:", "\\192.168.0.10\share‌​", PC-10\administrator, password` and it throws error division by 0. If i try just with administrator, password, after 5 seconds it says wrong username or password. If i map the drive manually and run the script then it works, but i can't do that for 100 pc's. – Cristian Muscalu Aug 16 '16 at 15:16
  • 1
    `administrator` is a variable right? As it stands its not the word "administrator" unless you have assigned to it, same for your other attempt it should be `WshNetwork.MapNetwo‌​‌​rkDrive "M:", "\\192.168.0.10\share‌​‌​", "PC-10\administrator", "your_password"` - note the quotes – Alex K. Aug 16 '16 at 15:19
  • I just tried it `WshNetwork.MapNetwo‌​‌​‌​rkDrive "M:", "\\192.168.0.10\share‌​‌​‌​", "PC-10\administrator‌​", "password"` with the quotes and it's throwing error `Type missmatch` – Cristian Muscalu Aug 16 '16 at 15:33
  • 2
    Consult documentation for the MapNetworkDrive command. If you don't specify the `[persistent]` parameter, you still need to have a placeholder there. https://msdn.microsoft.com/en-us/library/8kst88h6%28v=vs.84%29.aspx – langstrom Aug 16 '16 at 17:47

1 Answers1

1

Thanks @Alex K. and @langstrom for pointing the right directions.

Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "M:", "\\192.168.0.10\share", true, "BU-10\administrator", "password"
Cristian Muscalu
  • 9,007
  • 12
  • 44
  • 76