?
Solved

WSH..

Posted on 2003-02-19
6
Medium Priority
?
629 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:wzm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 200 total points
ID: 7985681
Try this:


<script>
 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);
  }
  alert(message)
</script>

0
 

Author Comment

by:wzm
ID: 7986990
My prog is saved as .js and saved on the desktop. I can get your codes to work.

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 7988767
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  
---------------------------

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:wzm
ID: 7991005
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

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 7996079
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.


0
 

Author Comment

by:wzm
ID: 8013560
I'm not sure what U meant since we are all connected the server. OS = 98

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question