Link to home
Start Free TrialLog in
Avatar of wzm
wzm

asked on

WSH..

How to make the Domain Name Come Out ?
I'm Connecting to the NetWork, But the The WshNetwork.UserDomain seems Nothing ,
Why ?

   var WshNetwork = new ActiveXObject("WScript.Network");
   var oDrives = WshNetwork.EnumNetworkDrives();
   var oPrinters = WshNetwork.EnumPrinterConnections();
   WScript.Echo("Domain = " + WshNetwork.UserDomain);
   WScript.Echo("Computer Name = " + WshNetwork.ComputerName);
   WScript.Echo("User Name = " + WshNetwork.UserName);
   WScript.Echo();
   WScript.Echo("Network drive mappings:");
   for(i=0; i<oDrives.Count(); i+=2){
      WScript.Echo("Drive " + oDrives.Item(i) + " = " + oDrives.Item(i+1));
   }
   WScript.Echo();
   WScript.Echo("Network printer mappings:");
   for(i=0; i<oPrinters.Count(); i+=2){
   WScript.Echo("Port " + oPrinters.Item(i) + " = " + oPrinters.Item(i+1));
   }



Cheers
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wzm
wzm

ASKER

My prog is saved as .js and saved on the desktop. I can get your codes to work.

I just tested this:

message="";
var WshNetwork = new ActiveXObject("WScript.Network");
 var oDrives = WshNetwork.EnumNetworkDrives();
 var oPrinters = WshNetwork.EnumPrinterConnections();
 message+="Domain = " + WshNetwork.UserDomain;
 message+="\nComputer Name = " + WshNetwork.ComputerName;
 message+="\nUser Name = " + WshNetwork.UserName;
 message+="\n";
 message+="\nNetwork drive mappings:";
 for(i=0; i<oDrives.Count(); i+=2){
    message+="\nDrive " + oDrives.Item(i) + " = " + oDrives.Item(i+1);
 }
 message+="\n";
 message+="\nNetwork printer mappings:";
 for(i=0; i<oPrinters.Count(); i+=2){
 message+="\nPort " + oPrinters.Item(i) + " = " + oPrinters.Item(i+1);
 }
 WScript.Echo(message)

and got this prompt:
---------------------------
Windows Script Host
---------------------------
Domain = HOMEWORKER
Computer Name = HOMEWORKER
User Name = Zvonko

Network drive mappings:

Network printer mappings:
Port LPT1: = EPSON Stylus C70 Series
---------------------------
OK  
---------------------------

Avatar of wzm

ASKER

Hi zenko, the point is yours definitely. Sorry Typo Error, It should be like this "I can't get your codes to work", Anyhow U have responsed to it with great speed.

This what I get ...

  Domain =
  Computer Name = HCSWAN
  User Name = HCSWAN
 
  Network drive mappings:

  Network printer mappings:
  Port LPT1:=Acrobat PDFWriter
  Port C:\WIndows\All Users\Desktop\*.pdf=Acrobat Distiller
  Port\\BaseDomino\4000it = HP LaserJet 4000 Series WKL 6

  ... Still The Domain is Not There.
  ... Should there be some setting ?


  Pls Help.

  Thanx

This is not a scripting problem.

You simply did not set a Domain name in your network settings.

You did not state which OS version you use, but anyway, look into TCPIP settings for DNS settings. There is a field Domain name. If this field is empty, then you can not read the value.


Avatar of wzm

ASKER

I'm not sure what U meant since we are all connected the server. OS = 98