Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

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
0
wzm
Asked:
wzm
  • 3
  • 3
1 Solution
 
ZvonkoSystems architectCommented:
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
 
wzmAuthor Commented:
My prog is saved as .js and saved on the desktop. I can get your codes to work.

0
 
ZvonkoSystems architectCommented:
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.

 
wzmAuthor Commented:
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
 
ZvonkoSystems architectCommented:
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
 
wzmAuthor Commented:
I'm not sure what U meant since we are all connected the server. OS = 98

0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now