0

I'm trying to access and run setup.exe from a server on the same network.

  • The pc where i'm trying to access the file from is in a domain.
  • The server is not in the domain.

This code works only if both pc's are without domain:

Set WshNetwork = WScript.CreateObject("WScript.Network")

WshNetwork.RemoveNetworkDrive "M:", True, True

WshNetwork.MapNetworkDrive "M:", "\\192.168.0.10\share", myUserName, myPassword

Set shell = WScript.CreateObject("Wscript.Shell")
shell.CurrentDirectory = "M:\Setup"
shell.Run("setup.exe"), 0 , True

WshNetwork.RemoveNetworkDrive "M:", True, True
  • If i try to run this code for my situation i get an error that username or password is wrong, but it isn't.
  • If i manually map the drive and run the code then it works
  • If i remove the map drive then the error is back.

What extra details do i have to add so the pc can access the file from the server?

Cristian Muscalu
  • 9,007
  • 12
  • 44
  • 76
  • If it is not in the domain then you need to have a local account setup on the server that matches your ID and PW, Then when you login use the computers name WshNetwork.MapNetworkDrive "M:", "\\192.168.0.10\share", \ID, PW – Sorceri Aug 12 '16 at 15:12
  • Until monday there is no way i can test this. I'll get back to you then. – Cristian Muscalu Aug 12 '16 at 16:37
  • I tried `WshNetwork.MapNetworkDrive "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. It must be something about the way i enter username and password i guess. – Cristian Muscalu Aug 16 '16 at 07:22
  • [here](http://stackoverflow.com/questions/631401/access-network-share-from-within-vbscript-eg-filesystemobject) it says `UserName = "domain\username"` , but i can't use that because it's not the same situation. The server is not in the domain while the pc's are. – Cristian Muscalu Aug 16 '16 at 07:28

0 Answers0