• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

Scripting

hello,

i'm trying to delete network printers via a registry key in a login script. I'm trying to make this registry key addition run silently, but everytime I test it a box comes up saying "Are you sure you want to add the information to the registry?"

Can anyone help?

The Registry key is:

Windows Registry Editor Version 5.1

[-HKEY_CURRENT_USER\Printers\Connections]


regedit.exe /s %LOGONSERVER%\DeleteAllPrinters.reg
0
COOPER143
Asked:
COOPER143
1 Solution
 
trywaredkCommented:
use regedit -s instead of regedit /s

Many Regards

Jorgen Malmgren
IT-Supervisor
Denmark
0
 
COOPER143Author Commented:
I tried that..Same message?
0
 
rolfejrCommented:
I do not believe you can silently import into the registry using regedit.  You can, however, do it with vbscript.  The machines running the loginscript would have to be able to run vbscripts (it should be on most windows machines unless you have specifically removed it).  Below is a sample script that reads a registry value, and if it is greater than or equal to 1, then it changes it to 0.

set wscr=CreateObject("WScript.Shell")
rr=wscr.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows Scripting Host\Settings\Timeout")
if (rr>=1) then
wscr.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows Scripting Host\Settings\Timeout",0,"REG_DWORD"
end if
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
oBdACommented:
Sigh - why is everybody trying to mess directly with the registry when there are enough official tools to achieve the desired goal?
To delete mapped network printers, you can either use (from the resource kit)
con2prt.exe /f
or
rundll32 printui.dll,PrintUIEntry /dn /n <printer name>
(try rundll32 printui.dll,PrintUIEntry /? for a list of possible switches; note that PrintUIEntry is case sensitive.)
0
 
pbarretteCommented:
Hi COOPER143,

And, yes, you can use REGEDIT /S to update the registry silently.

If you are determined to use the registry (instead of oBdA's elegant answer) you may want to try using the "REG DELETE /?" command and view the options presented there.

pb
0
 
COOPER143Author Commented:
I forgot about the con2prt.exe /f....

It worked great!

Thanks for everyone's help.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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