|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Deleting and re-installing printer with new name using login scripI want to change the naming standard for all printers in my company. This goes for both the sharenames and printer names. The idea is that I'll do this outside normal working hours and then for a period of time update the login script so that it first checks if a network printer is installed, and if this is the case it deletes the network printer and then re-installs it with the new name. This will be done for each network printer in the company, and if the printer isn't installed on the specific pc the script will just move on to check for the next printer. However I can't get this to work properly. This is an example of the script for a printer with old printer name OKI C5600 and sharename OKIC5600 and new printer name Herlev - Stuen - ANBL - Oki C5600 and sharename ANBLOkiC5600: if not exist \\fs\OKIC5600 goto ok_OKIC5600 rundll32 printui.dll,PrintUIEntry /dn /n\\fs\OKIC5600 /j"OKI C5600" rundll32 printui.dll,PrintUIEntry /in /n\\fs\ANBLOkiC5600 /j"Herlev - Stuen - ANBL - Oki C5600" :ok_OKIC5600 Can anybody tell me why this isn't working? If I rem out the first line the printer is succesfully deleted, so there must be a problem in the "if not exist......" line. Thanks in advance, Ronnie
Show quote
Hide quote
"Ronnie" <Ron***@discussions.microsoft.com> wrote in message Is \\fs\OKIC5600 a file or a folder, and does it exist?news:54F04EC9-9899-4867-A380-B819C244224D@microsoft.com... > Hi all, > > I want to change the naming standard for all printers in my company. This > goes for both the sharenames and printer names. The idea is that I'll do > this > outside normal working hours and then for a period of time update the > login > script so that it first checks if a network printer is installed, and if > this > is the case it deletes the network printer and then re-installs it with > the > new name. This will be done for each network printer in the company, and > if > the printer isn't installed on the specific pc the script will just move > on > to check for the next printer. However I can't get this to work properly. > > This is an example of the script for a printer with old printer name OKI > C5600 and sharename OKIC5600 and new printer name Herlev - Stuen - ANBL - > Oki > C5600 and sharename ANBLOkiC5600: > > if not exist \\fs\OKIC5600 goto ok_OKIC5600 > rundll32 printui.dll,PrintUIEntry /dn /n\\fs\OKIC5600 /j"OKI C5600" > rundll32 printui.dll,PrintUIEntry /in /n\\fs\ANBLOkiC5600 /j"Herlev - > Stuen > - ANBL - Oki C5600" > :ok_OKIC5600 > > Can anybody tell me why this isn't working? If I rem out the first line > the > printer is succesfully deleted, so there must be a problem in the "if not > exist......" line. /Al
Show quote
Hide quote
"Al Dunbar" wrote: fs is the name of the file server and OKIC5600 is the old sharename for the > > "Ronnie" <Ron***@discussions.microsoft.com> wrote in message > news:54F04EC9-9899-4867-A380-B819C244224D@microsoft.com... > > Hi all, > > > > I want to change the naming standard for all printers in my company. This > > goes for both the sharenames and printer names. The idea is that I'll do > > this > > outside normal working hours and then for a period of time update the > > login > > script so that it first checks if a network printer is installed, and if > > this > > is the case it deletes the network printer and then re-installs it with > > the > > new name. This will be done for each network printer in the company, and > > if > > the printer isn't installed on the specific pc the script will just move > > on > > to check for the next printer. However I can't get this to work properly. > > > > This is an example of the script for a printer with old printer name OKI > > C5600 and sharename OKIC5600 and new printer name Herlev - Stuen - ANBL - > > Oki > > C5600 and sharename ANBLOkiC5600: > > > > if not exist \\fs\OKIC5600 goto ok_OKIC5600 > > rundll32 printui.dll,PrintUIEntry /dn /n\\fs\OKIC5600 /j"OKI C5600" > > rundll32 printui.dll,PrintUIEntry /in /n\\fs\ANBLOkiC5600 /j"Herlev - > > Stuen > > - ANBL - Oki C5600" > > :ok_OKIC5600 > > > > Can anybody tell me why this isn't working? If I rem out the first line > > the > > printer is succesfully deleted, so there must be a problem in the "if not > > exist......" line. > > Is \\fs\OKIC5600 a file or a folder, and does it exist? > > /Al > > > printer which I by the time the script is supposed to run will have changed to ANBLOkiC5600. Regards, Ronnie
Show quote
Hide quote
"Ronnie" wrote: I actually think the problem is that "if not exist \\fs\OKIC5600 goto > > > "Al Dunbar" wrote: > > > > > "Ronnie" <Ron***@discussions.microsoft.com> wrote in message > > news:54F04EC9-9899-4867-A380-B819C244224D@microsoft.com... > > > Hi all, > > > > > > I want to change the naming standard for all printers in my company. This > > > goes for both the sharenames and printer names. The idea is that I'll do > > > this > > > outside normal working hours and then for a period of time update the > > > login > > > script so that it first checks if a network printer is installed, and if > > > this > > > is the case it deletes the network printer and then re-installs it with > > > the > > > new name. This will be done for each network printer in the company, and > > > if > > > the printer isn't installed on the specific pc the script will just move > > > on > > > to check for the next printer. However I can't get this to work properly. > > > > > > This is an example of the script for a printer with old printer name OKI > > > C5600 and sharename OKIC5600 and new printer name Herlev - Stuen - ANBL - > > > Oki > > > C5600 and sharename ANBLOkiC5600: > > > > > > if not exist \\fs\OKIC5600 goto ok_OKIC5600 > > > rundll32 printui.dll,PrintUIEntry /dn /n\\fs\OKIC5600 /j"OKI C5600" > > > rundll32 printui.dll,PrintUIEntry /in /n\\fs\ANBLOkiC5600 /j"Herlev - > > > Stuen > > > - ANBL - Oki C5600" > > > :ok_OKIC5600 > > > > > > Can anybody tell me why this isn't working? If I rem out the first line > > > the > > > printer is succesfully deleted, so there must be a problem in the "if not > > > exist......" line. > > > > Is \\fs\OKIC5600 a file or a folder, and does it exist? > > > > /Al > > > > > > > fs is the name of the file server and OKIC5600 is the old sharename for the > printer which I by the time the script is supposed to run will have changed > to ANBLOkiC5600. > > Regards, > Ronnie ok_OKIC5600" looks for a printer with the sharename OKIC5600 on the print server named fs, and this no longer exists since I've changed the sharename to ANBLOkiC5600, and because this no longer exists on the print server it goes to ":ok_OKIC5600". So the challenge is to change the \\fs\OKIC5600 part to instead search for the network printer on the local pc, but how can I do this so it works for all pc's in the domain? Is there a command to select the local pc name like you can use "%username%" to specify the user logged in on a pc? Regards, Ronnie
Show quote
Hide quote
"Ronnie" <Ron***@discussions.microsoft.com> wrote in message IF ? sheds a bit of light on what this means:news:CF326F1F-AE4A-4D1C-AEB6-2258DDA13FB7@microsoft.com... > > > "Ronnie" wrote: > >> >> >> "Al Dunbar" wrote: >> >> > >> > "Ronnie" <Ron***@discussions.microsoft.com> wrote in message >> > news:54F04EC9-9899-4867-A380-B819C244224D@microsoft.com... >> > > Hi all, >> > > >> > > I want to change the naming standard for all printers in my company. >> > > This >> > > goes for both the sharenames and printer names. The idea is that I'll >> > > do >> > > this >> > > outside normal working hours and then for a period of time update the >> > > login >> > > script so that it first checks if a network printer is installed, and >> > > if >> > > this >> > > is the case it deletes the network printer and then re-installs it >> > > with >> > > the >> > > new name. This will be done for each network printer in the company, >> > > and >> > > if >> > > the printer isn't installed on the specific pc the script will just >> > > move >> > > on >> > > to check for the next printer. However I can't get this to work >> > > properly. >> > > >> > > This is an example of the script for a printer with old printer name >> > > OKI >> > > C5600 and sharename OKIC5600 and new printer name Herlev - Stuen - >> > > ANBL - >> > > Oki >> > > C5600 and sharename ANBLOkiC5600: >> > > >> > > if not exist \\fs\OKIC5600 goto ok_OKIC5600 >> > > rundll32 printui.dll,PrintUIEntry /dn /n\\fs\OKIC5600 /j"OKI C5600" >> > > rundll32 printui.dll,PrintUIEntry /in /n\\fs\ANBLOkiC5600 /j"Herlev - >> > > Stuen >> > > - ANBL - Oki C5600" >> > > :ok_OKIC5600 >> > > >> > > Can anybody tell me why this isn't working? If I rem out the first >> > > line >> > > the >> > > printer is succesfully deleted, so there must be a problem in the "if >> > > not >> > > exist......" line. >> > >> > Is \\fs\OKIC5600 a file or a folder, and does it exist? >> > >> > /Al >> > >> > >> > >> fs is the name of the file server and OKIC5600 is the old sharename for >> the >> printer which I by the time the script is supposed to run will have >> changed >> to ANBLOkiC5600. >> >> Regards, >> Ronnie > > I actually think the problem is that "if not exist \\fs\OKIC5600 goto > ok_OKIC5600" looks for a printer IF [NOT] EXIST filename command so it would appear that it knows little of shared printers, and deals only with file-related objects. > with the sharename OKIC5600 on the print of because no shared folder exists by that name.> server named fs, and this no longer exists since I've changed the > sharename > to ANBLOkiC5600, and because this no longer exists on the print server it > goes to ":ok_OKIC5600". > So the challenge is to change the \\fs\OKIC5600 part to instead search for You could use \\%computername%\share to test for the existence of a > the network printer on the local pc, but how can I do this so it works for > all pc's in the domain? Is there a command to select the local pc name > like > you can use "%username%" to specify the user logged in on a pc? specified shared folder on the local computer, but I do not think that is the way to go. First, and as already stated, IF EXIST looks for file type objects. Second, even if the method would work, it would only detect printers shared out by the PC, not those shared out by a server and only referenced by a user on the PC. I'm not sure of a simple way to accomplish what you want using batch, but suspect it would be relatively simple to do with vbscript/WSH using the network object: http://msdn.microsoft.com/en-us/library/kxy72898(VS.85).aspx /Al
Show quote
Hide quote
"Ronnie" <Ron***@discussions.microsoft.com> wrote in message .... in which case the if not exist would seem to always succeed - even if news:C5A551DB-3070-4F54-8352-75C2C7E061E4@microsoft.com... > > > "Al Dunbar" wrote: > >> >> "Ronnie" <Ron***@discussions.microsoft.com> wrote in message >> news:54F04EC9-9899-4867-A380-B819C244224D@microsoft.com... >> > Hi all, >> > >> > I want to change the naming standard for all printers in my company. >> > This >> > goes for both the sharenames and printer names. The idea is that I'll >> > do >> > this >> > outside normal working hours and then for a period of time update the >> > login >> > script so that it first checks if a network printer is installed, and >> > if >> > this >> > is the case it deletes the network printer and then re-installs it with >> > the >> > new name. This will be done for each network printer in the company, >> > and >> > if >> > the printer isn't installed on the specific pc the script will just >> > move >> > on >> > to check for the next printer. However I can't get this to work >> > properly. >> > >> > This is an example of the script for a printer with old printer name >> > OKI >> > C5600 and sharename OKIC5600 and new printer name Herlev - Stuen - >> > ANBL - >> > Oki >> > C5600 and sharename ANBLOkiC5600: >> > >> > if not exist \\fs\OKIC5600 goto ok_OKIC5600 >> > rundll32 printui.dll,PrintUIEntry /dn /n\\fs\OKIC5600 /j"OKI C5600" >> > rundll32 printui.dll,PrintUIEntry /in /n\\fs\ANBLOkiC5600 /j"Herlev - >> > Stuen >> > - ANBL - Oki C5600" >> > :ok_OKIC5600 >> > >> > Can anybody tell me why this isn't working? If I rem out the first line >> > the >> > printer is succesfully deleted, so there must be a problem in the "if >> > not >> > exist......" line. >> >> Is \\fs\OKIC5600 a file or a folder, and does it exist? >> >> /Al >> >> >> > fs is the name of the file server and OKIC5600 is the old sharename for > the > printer which I by the time the script is supposed to run will have > changed > to ANBLOkiC5600. the printers in the local profile stil had a reference to it. I know that if exist can test the existence of a shared folder by giving its UNC, but I don't know if this works for a UNC to a non-NTFS object such as a shared printer. /Al
Batch Script to parse lines in text file
Command line parameters? Get attributes of user list from AD run once script Monitor redundent processes running on the Windows Server WMI Script, access denied? send mail if ping faile Script for deleting folders + content in root of D:\ after # days Batch file to delete files dynamically Script to set user permissions |
|||||||||||||||||||||||