Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 27th, 2004, 10:58 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default Network printer addresses

Hi Guys,

If I wanted to write a script, (or even just a bit of HTML), to add a network printer to a user's machine, whats the format? For example, my server name is CSD2, and the machine address is WBBE6162, therefor the machine address on the network would be: \\CSD2\WBBE6162. The printer name would be CRMB2. So my FQ printer address should look like this: \\CSD2\WBBE6162\CRMB2. However, I can't figure out how I can add the printer through Javascript. Any ideas?

cheers all
interrupt

__________________
\'sync\' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
Reply With Quote
  #2 (permalink)  
Old August 27th, 2004, 04:01 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I seriously doubt there is a way, even with security on the lowest level.

Perhaps there is a way with ActiveX, but I would go with VB.NET or some other Microsoft programming language that can interact with such settings.

I realize this probably wasn't the answer you were looking for, but... :-(

Snib

<><
Reply With Quote
  #3 (permalink)  
Old August 28th, 2004, 02:28 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

The WScript.Network class has two methods for adding printers, one of these might suit you:

http://msdn.microsoft.com/library/de...wshnetwork.asp



--

Joe (Co-author Beginning XML, 3rd edition)
Reply With Quote
  #4 (permalink)  
Old September 2nd, 2004, 08:09 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This works with security down as Snib suggested. Is there a way of marking the wshNetwork object as safe for scripting?

cheers
interrupt

Reply With Quote
  #5 (permalink)  
Old September 2nd, 2004, 09:19 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Yes but as it's not it would be a huge security risk. If this is for an intranet just have your users lower the settings for that section.

--

Joe
Reply With Quote
  #6 (permalink)  
Old September 2nd, 2004, 09:27 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,

None of my users have access to the internet. It is stricty intranet based and none of them would know how to play with stuff like this. If I ask them to lower security settings they will get confused lol. And if I have to do it, it means running around each machine for over 200 users. So any way of getting this marked safe for scripting would be welcome.

cheers
interrupt

Reply With Quote
  #7 (permalink)  
Old September 2nd, 2004, 10:37 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well you'd have to do it from the machine itself, so your no better off. You can ask them to run a stand-alone script that would change their registry settings, the one I use is below. This assumes that the security zone is "Local Intranet", and that must be showing in the status bar. You probably want to change some of the stuff relating to a proxy server etc. A good link to what settings mean is:

http://support.microsoft.com/default...EN-US;q182569&

Code:
/* 
   This script updates the security settings and home page settings
   to enable ActiveX components to run from pages delivered by our intranet.
   It can be run with messages or silently by adding the /q switch.
   Author: Joe Fawcett 0370 476 089 - Version 1.0 - 27 March 2000
                                      Version 1.1 - 31 May 2001 
                                      Version 1.2 - 2001-12-17 
                                      Version 1.3 - 2002-11-07 altered '1A00' to allow Windows integrated authentication.
*/

var L_PROXY_IP = "http://10.100.0.30:80";

var buttonNo = 7; 
var buttonsYesNo = 4;
var QUESTION = 32;
var EXCLAMATION = 48;
var INFORMATION = 64;
var SILENT = false;
var oShell;
var vRegKeys = new Array(3);
var sRegMainKey;
var sRegLocationSecurityLocal;
var sRegLocationSecurityCurrent;
var sRegLocationProxyCurrent;

function exitApp(sMessage, lIconType){
  if(!SILENT) oShell.Popup(sMessage, 0, "End", lIconType);
  oShell = null;
  WScript.Quit();
  return;
}

function determineMode(){
  oShell = WScript.CreateObject("WScript.Shell");  
  var sArg;
  for(var i = 0; i < WScript.Arguments.length; i++){
      sArg = WScript.Arguments(i).toLowerCase();       
      if(sArg == "/q" || sArg == "-q") SILENT = true;
  }
  return;
} 

function checkRun(){
  if(!SILENT){
     if((oShell.PopUP("Do you wish to update your browser settings?", 0, "Update?", buttonsYesNo + QUESTION)) == buttonNo){
         exitApp("Settings not updated", INFORMATION);
     }
  }
  return;       
}  

function setKeys(){
  for(var j = 0;j < vRegKeys.length;j++)vRegKeys[j] = new Array(29);  
  vRegKeys[0][0] = "1001";
  vRegKeys[1][0] = 0;
  vRegKeys[2][0] = "REG_DWORD"; 
  vRegKeys[0][1] = "1004";
  vRegKeys[1][1] = 0;
  vRegKeys[2][1] = "REG_DWORD"; 
  vRegKeys[0][2] = "1200";
  vRegKeys[1][2] = 0;
  vRegKeys[2][2] = "REG_DWORD"; 
  vRegKeys[0][3] = "1201";
  vRegKeys[1][3] = 0;
  vRegKeys[2][3] = "REG_DWORD"; 
  vRegKeys[0][4] = "1400";
  vRegKeys[1][4] = 0;
  vRegKeys[2][4] = "REG_DWORD"; 
  vRegKeys[0][5] = "1402";
  vRegKeys[1][5] = 0;
  vRegKeys[2][5] = "REG_DWORD"; 
  vRegKeys[0][6] = "1405";
  vRegKeys[1][6] = 0;
  vRegKeys[2][6] = "REG_DWORD";
  vRegKeys[0][7] = "1406";
  vRegKeys[1][7] = 0;
  vRegKeys[2][7] = "REG_DWORD"; 
  vRegKeys[0][8] = "1601";
  vRegKeys[1][8] = 0;
  vRegKeys[2][8] = "REG_DWORD"; 
  vRegKeys[0][9] = "1604";
  vRegKeys[1][9] = 0;
  vRegKeys[2][9] = "REG_DWORD"; 
  vRegKeys[0][10] = "1605";
  vRegKeys[1][10] = 0;
  vRegKeys[2][10] = "REG_DWORD"; 
  vRegKeys[0][11] = "1800";
  vRegKeys[1][11] = 3;
  vRegKeys[2][11] = "REG_DWORD"; 
  vRegKeys[0][12] = "1802";
  vRegKeys[1][12] = 0;
  vRegKeys[2][12] = "REG_DWORD"; 
  vRegKeys[0][13] = "1803";
  vRegKeys[1][13] = 0;
  vRegKeys[2][13] = "REG_DWORD";      
  vRegKeys[0][14] = "1804";
  vRegKeys[1][14] = 0;
  vRegKeys[2][14] = "REG_DWORD"; 
  vRegKeys[0][15] = "1805";
  vRegKeys[1][15] = 0;
  vRegKeys[2][15] = "REG_DWORD"; 
  vRegKeys[0][16] = "1A00";
  vRegKeys[1][16] = 0x0;
  vRegKeys[2][16] = "REG_DWORD"; 
  vRegKeys[0][17] = "1C00";
  vRegKeys[1][17] = 196608;
  vRegKeys[2][17] = "REG_DWORD"; 
  vRegKeys[0][18] = "1E05";
  vRegKeys[1][18] = 196608;
  vRegKeys[2][18] = "REG_DWORD";  
  vRegKeys[0][19] = "CurrentLevel";  
  vRegKeys[1][19] = 4096;
  vRegKeys[2][19] = "REG_DWORD"; 
  vRegKeys[0][20] = "Description";
  vRegKeys[1][20] = "This zone contains all sites on the Chesterton intranet";
  vRegKeys[2][20] = "REG_SZ";
  vRegKeys[0][21] = "DisplayName";
  vRegKeys[1][21] = "Chesterton Intranet";
  vRegKeys[2][21] = "REG_SZ";
  vRegKeys[0][22] = "Flags";
  vRegKeys[1][22] = 201; 
  vRegKeys[2][22] = "REG_DWORD"; 
  vRegKeys[0][23] = "Icon";
  vRegKeys[1][23] = "Shell32.dll#0018";
  vRegKeys[2][23] = "REG_SZ";
  vRegKeys[0][24] = "MinLevel";
  vRegKeys[1][24] = 4096;
  vRegKeys[2][24] = "REG_DWORD"; 
  vRegKeys[0][25] = "RecommendedLevel";
  vRegKeys[1][25] = 4096;
  vRegKeys[2][25] = "REG_DWORD"; 
  vRegKeys[0][26] = "ProxyEnable";
  vRegKeys[1][26] = 1;
  vRegKeys[2][26] = "REG_DWORD"; 
  vRegKeys[0][27] = "ProxyOverride";
  vRegKeys[1][27] = "10.*;<local>";
  vRegKeys[2][27] = "REG_SZ";
  vRegKeys[0][28] = "ProxyServer";
  vRegKeys[1][28] = L_PROXY_IP;  
  vRegKeys[2][28] = "REG_SZ"; 

  sRegMainKey = "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\";
  sRegLocationSecurityLocal = "HKLM" + sRegMainKey + "Zones\\1\\";
  sRegLocationSecurityCurrent = "HKCU" + sRegMainKey + "Zones\\1\\";  
  sRegLocationProxyCurrent = "HKCU" + sRegMainKey;
  return;
}

function putKeys(){    
  for(var i = 0;i < 26; i++){
      oShell.RegWrite(sRegLocationSecurityLocal + vRegKeys[0][i], vRegKeys[1][i], vRegKeys[2][i]); 
      oShell.RegWrite(sRegLocationSecurityCurrent + vRegKeys[0][i], vRegKeys[1][i], vRegKeys[2][i]); 
      //WScript.Echo(i + "\n" + sRegLocationSecurityLocal + vRegKeys[0][i] + "\n" + vRegKeys[1][i] + "\n" + vRegKeys[2][i]);       
      //WScript.Echo(i + "\n" + sRegLocationSecurityCurrent + vRegKeys[0][i] + "\n" + vRegKeys[1][i] + "\n" + vRegKeys[2][i]);        
  }
  for(var i = 26; i < 29; i++){
      oShell.RegWrite(sRegLocationProxyCurrent + vRegKeys[0][i], vRegKeys[1][i], vRegKeys[2][i]); 
      //WScript.Echo(i + "\n" + sRegLocationProxyCurrent + vRegKeys[0][i] + "\n" + vRegKeys[1][i] + "\n" + vRegKeys[2][i]);       
  } 
  return;
}

  determineMode();
  checkRun(); 
  setKeys();
  putKeys();
  exitApp("Done", INFORMATION);
--

Joe
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Printer on different Network ayazhoda Windows Server 1 November 18th, 2007 01:34 PM
Printer.Printer Problem!! Pls Help Me Chamin Access VBA 0 December 10th, 2004 07:08 AM



All times are GMT -4. The time now is 10:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.