Windows 7:
cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g
Windows XP:
cscript C:\windows\system32\prnmngr.vbs -g
These will get the default printer of the current system. I was wondering if there is a way to run this on my computer to get the default printer of a remote computer by computer name?
I tried running:
psexec \\c78572 -i -d cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g
And it appears to run.. but I only see the results in a quick popup cmd line window on the remote computer and not on mine. All I see on my end is:
cscript started with process ID 568.
In powershell gwmi win32_printer -computername c78572
works.. but I don't know how to sort it to show me the default printer.
EDIT 12/20/13 I am trying to combine it with a show all printers and the default but I can't get it to work:
while (1) {
$tag1 = Read-Host 'Enter tag # or Q to quit'
if ($tag1 -eq "Q") {
break;
}
cls
sc.exe \\$tag1 start RemoteRegistry;
cls
start-sleep -seconds 2
cls
$OSInfo = get-wmiobject -class win32_operatingsystem -computername $tag1;
$OSInfo | Format-Table -Property @{Name="OS Name";Expression={$_.Caption}},@{Name="System Boot Time";Expression={$_.ConvertToDateTime($_.LastBootUpTime)}} -AutoSize;
gwmi win32_printer -computername $tag1 | ft -Property @{Name="Printer Name";Expression={$_.Name}} -AutoSize;
$Computer = $tag1
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('currentuser', $Computer)
$RegKey= $Reg.OpenSubKey('Software\Microsoft\Windows NT\CurrentVersion\Windows')
$DefaultPrinter = $RegKey.GetValue("Device")
$DefaultPrinter | ConvertFrom-Csv -Header Name, Provider, Order| Select Name
# Alt method: Get-WmiObject win32_printer -computername c60311
}