Variables

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Does anyone know if there a variable for the Default
Printer in Windows 2000? I tried %Default_Printer%, but
it does not work. I can't find a list of Windows 2000
variables anywhere.

Thanks,
Mike
 
To see a list of your environment variables, type the SET command with no
arguments. Keep in mind that any variables added by any installed programs,
and any variables you've added yourself, will appear as well.

Here's the command to set "printer" as default:

rundll32 printui.dll,PrintUIEntry /y /n "printer"

For a complete list of options, type this command:

rundll32 printui.dll,PrintUIEntry /?

David
Stardate 3832.0
 
Mike said:
Does anyone know if there a variable for the Default
Printer in Windows 2000? I tried %Default_Printer%, but
it does not work. I can't find a list of Windows 2000
variables anywhere.

Thanks,
Mike

I know of no environment variable that is pre-populated with that
information. The enclosed text file is a shell script (batch file) that
will set the environment variable DEFAULTPRINTER to the name of the
current user's default printer.

HTH

Dean
 
Dean,

This sounds like exactly what I need. But, I do not see
any text(batch) file enclosed here. Can you plese send to
my email address. Sorry, sent you a direct email too.

Thanks,
Mike
-----Original Message-----
Mike said:
Does anyone know if there a variable for the Default
Printer in Windows 2000? I tried %Default_Printer%, but
it does not work. I can't find a list of Windows 2000
variables anywhere.

Thanks,
Mike

I know of no environment variable that is pre-populated with that
information. The enclosed text file is a shell script (batch file) that
will set the environment variable DEFAULTPRINTER to the name of the
current user's default printer.

HTH

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
 
Mike said:
Dean,

This sounds like exactly what I need. But, I do not see
any text(batch) file enclosed here.

Hi

Here is what Dean posted:


@echo off

:: Obtains current user's default printer and assigns its name to the DEFAULTPRINTER environment variable

regedit /a %TEMP%\defaultPRN.reg "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
for /f "tokens=2 delims==," %%p in ('type %TEMP%\defaultPRN.reg ^| findstr "Device"') do (
set DEFAULTPRINTER=%%~p
)
del %TEMP%\defaultPRN.reg 2>nul
 
Does anyone know if there a variable for the Default
Printer in Windows 2000? I tried %Default_Printer%, but
it does not work. I can't find a list of Windows 2000
variables anywhere.

Thanks,
Mike


To set a variable to the user's default printer, use
call dfltprt prt
which is defined at tip 7280 in the 'Tips & Tricks' at http://www.jsiinc.com

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Mike said:
Dean,

This sounds like exactly what I need. But, I do not see
any text(batch) file enclosed here. Can you plese send to
my email address. Sorry, sent you a direct email too.

Thanks,
Mike
-----Original Message-----
Mike said:
Does anyone know if there a variable for the Default
Printer in Windows 2000? I tried %Default_Printer%, but
it does not work. I can't find a list of Windows 2000
variables anywhere.

Thanks,
Mike

I know of no environment variable that is pre-populated with that
information. The enclosed text file is a shell script (batch file)
that will set the environment variable DEFAULTPRINTER to the name of
the current user's default printer.

HTH

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l

My apologies ... due to the line length and the confusion caused with
broken lines I tried to simplify things and apparently achieved the
exact opposite. Hopefully, the later pasted reply will suffice.

Dean
 
In said:
Mike said:
Dean,

This sounds like exactly what I need. But, I do not see
any text(batch) file enclosed here. Can you plese send to
my email address. Sorry, sent you a direct email too.

Thanks,
Mike
-----Original Message-----
Mike wrote:
Does anyone know if there a variable for the Default
Printer in Windows 2000? I tried %Default_Printer%, but
it does not work. I can't find a list of Windows 2000
variables anywhere.

Thanks,
Mike

I know of no environment variable that is pre-populated with
that information. The enclosed text file is a shell script
(batch file) that will set the environment variable
DEFAULTPRINTER to the name of the current user's default
printer.

HTH

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l

My apologies ... due to the line length and the confusion caused
with broken lines I tried to simplify things and apparently
achieved the exact opposite. Hopefully, the later pasted reply
will suffice.

Dean

Mike:
"X-Newsreader: Microsoft CDO for Windows 2000"

I don't know but is it that that newsreader cannot see attachments?
I think your code as a .TXT attachment was fine, in general.
 
Mark said:
In said:
Mike said:
Dean,

This sounds like exactly what I need. But, I do not see
any text(batch) file enclosed here. Can you plese send to
my email address. Sorry, sent you a direct email too.

Thanks,
Mike

-----Original Message-----
Mike wrote:
Does anyone know if there a variable for the Default
Printer in Windows 2000? I tried %Default_Printer%, but
it does not work. I can't find a list of Windows 2000
variables anywhere.

Thanks,
Mike

I know of no environment variable that is pre-populated with
that information. The enclosed text file is a shell script
(batch file) that will set the environment variable
DEFAULTPRINTER to the name of the current user's default
printer.

HTH

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l

My apologies ... due to the line length and the confusion caused
with broken lines I tried to simplify things and apparently
achieved the exact opposite. Hopefully, the later pasted reply
will suffice.

Dean

Mike:
"X-Newsreader: Microsoft CDO for Windows 2000"

I don't know but is it that that newsreader cannot see attachments?
I think your code as a .TXT attachment was fine, in general.

It usually occurs when the post is retrieved from a news server other
than those provided by Microsoft, some of these servers do not permit
enclosures.

Dean
 
Mark said:
Mike:
"X-Newsreader: Microsoft CDO for Windows 2000"

I don't know but is it that that newsreader cannot see attachments?
I think your code as a .TXT attachment was fine, in general.

Correct, that is the Web Interface that Microsoft have to the newsgroups, and
attachments are disabled there.
 
Dean,

I used your batch file in a test. It turns out that when
the batch file retrieves the default printer information
from the registry, it returns a value like:

\\\\servername\\printername

So, using regedit, I did an export on the registry key,
and I get the same value, \\\\servername\\printername,
even though the correct format, \\servername\printername,
is listed as the registry value when using regedit.

Since I know the servername will be the same for all the
printers, I was able to get around it by adding the
following to your batch file:

set DEFAULTPRINTER=%DEFAULTPRINTER:~13%

This truncated the 1st 13 characters, getting rid of all
the \'s.

Then I used:

net use lpt1: \\servername\%DEFAULTPRINTER% /persistent:yes

That appears to work on 2000 and XP.

Any ideas on how to get the correct default printer value
out of the registry, using your script?

Thanks again,
Mike


-----Original Message-----
Mike said:
Does anyone know if there a variable for the Default
Printer in Windows 2000? I tried %Default_Printer%, but
it does not work. I can't find a list of Windows 2000
variables anywhere.

Thanks,
Mike

I know of no environment variable that is pre-populated with that
information. The enclosed text file is a shell script (batch file) that
will set the environment variable DEFAULTPRINTER to the name of the
current user's default printer.

HTH

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
 
Mike said:
Dean,

I used your batch file in a test. It turns out that when
the batch file retrieves the default printer information
from the registry, it returns a value like:

\\\\servername\\printername

So, using regedit, I did an export on the registry key,
and I get the same value, \\\\servername\\printername,
even though the correct format, \\servername\printername,
is listed as the registry value when using regedit.

Since I know the servername will be the same for all the
printers, I was able to get around it by adding the
following to your batch file:

set DEFAULTPRINTER=%DEFAULTPRINTER:~13%

This truncated the 1st 13 characters, getting rid of all
the \'s.

Then I used:

net use lpt1: \\servername\%DEFAULTPRINTER% /persistent:yes

That appears to work on 2000 and XP.

Any ideas on how to get the correct default printer value
out of the registry, using your script?

Thanks again,
Mike

Add the following line to the bottom of the script -

set DEFAULTPRINTER=%DEFAULTPRINTER:\\=\%

Since I can't seem to easily repro. your registry values I can only say
that I hope the modification I've outlined above will work in all
environments but I certainly cannot guarantee it.

Dean
 
-----Original Message-----
Mike said:
Dean,

I used your batch file in a test. It turns out that when
the batch file retrieves the default printer information
from the registry, it returns a value like:

\\\\servername\\printername

So, using regedit, I did an export on the registry key,
and I get the same value, \\\\servername\\printername,
even though the correct format, \\servername\printername,
is listed as the registry value when using regedit.

Since I know the servername will be the same for all the
printers, I was able to get around it by adding the
following to your batch file:

set DEFAULTPRINTER=%DEFAULTPRINTER:~13%

This truncated the 1st 13 characters, getting rid of all
the \'s.

Then I used:

net use lpt1: \\servername\% DEFAULTPRINTER% /persistent:yes

That appears to work on 2000 and XP.

Any ideas on how to get the correct default printer value
out of the registry, using your script?

Thanks again,
Mike

Add the following line to the bottom of the script -

set DEFAULTPRINTER=%DEFAULTPRINTER:\\=\%

Since I can't seem to easily repro. your registry values I can only say
that I hope the modification I've outlined above will work in all
environments but I certainly cannot guarantee it.

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


.
Works very nicely. Thanks very much.
Mike
 
Back
Top