I need to change the setting in the print properties that specifies either: 1. "Spool print documents..." or 2. "Print directly to the printer."
In this answer J... indicates that this can be done using the PrintQueue Class. How?
MSDN PrintQueue.isDirect (ReadOnly Property) says this: "This property can be set only
through the Windows common print dialog."
I assume that applies specifically to .net and may not be true in the absolute sense. So how to change the spool/print direct setting via code?
From comment of J...
Quoting from: Windows Spooler Registry
Various printer options can be set via the windows registry. Each
installed printer has a subkey in the following Registry path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\
Under this there is a attributes bitmap, in the value Attributes :
REG_DWORD 0002 (0x0002) Direct: Document to be sent directly to the
printer.
The spooler service might need to be restarted, for the changes to
take effect.
Note that this registry value contains multiple attributes. See Windows Spooler Registry for more details.
Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. Modify the registry at your own risk.
Related
I am trying to find a commandline method for setting the Enable actions for stops with errors check box in the Recovery tab of a service's properties dialogue.
I know that when I change the value of the check box and hit apply, in the registry the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<serviceName>\FailureActionsOnNonCrashFailures key is modified to be either 0 or 1.
However, it seems that something else on the system must be changing because manually setting the registry key value is not enough to turn that check box on or off in the dialogue UI, and it's not enough to change the value returned when running sc qfailureflag <servicename>.
Even running sc failureflag <servicename> flag=1 or flag=0 does not change the value returned by sc qfailureflag <servicename> and does not affect the check box in UI, and indeed does not even seem to change the value of that registry key, even though checking or unchecking the box in the UI does change that key's value.
The only method I can find that seems to have any effect on whether that flag is truly 'set' or not, is clicking in the UI. Clicking in the UI does change both the registry key and the value returned by sc qfailureflag
Since I'm trying to write a configuration script that will set this flag automatically, clicking in the UI is not an option.
If anyone knows what else is changing on the system to set or un set this flag I would love to know, and if you know an automated way to set it that would be even better. Ideally some mix of PowerShell and C# would be great too, but honestly I would settle for just knowing what is changing on the system that I'm not seeing.
I know you had your answer in a comment, but to make it easier for the next person, here is what I have done:
//enables actions for stops with errors
sc.exe failureflag "my.local.windowsservice" 1
//disables actions for stops with errors
sc.exe failureflag "my.local.windowsservice" 0
Hopefully this question has a simple answer i'm overlooking! I have an IIS webserver with multiple sites on it. In Perfmon, they show up as w3wp#1, w3wp#2, etc... I'm writing a Logman script that will collect performance counter data using the counters/instances that I specify and I want to ONLY collect any w3wp worker processes.
I've tried a couple ways, but no luck:
\.NET CLR Memory(*w3wp*)\
\.NET CLR Memory(w3wp#*)\
\.NET CLR Memory(w3wp*)\
I've looked at the documentation here, and it seems like it claims to support wildcards, but not partial matches. I'm not sure what to make of that. Is there any way accomplish what I want? Hope I explained this well enough. Let me know if more details are needed.
Thanks!
There is a way to display the instance by appending Process Id to it. Since ProcessId do not change it helps determining the correct instance. This post describes the method - Perfmon: Identifying processes by PID instead of instance.
Relevant part from the link:
Making below registry change will display processes in the format of **ProcessName_PID** instead of **ProcessName#1**.
Click Start, click Run, type regedit, and then click OK.
Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance
On the Edit menu, click New, and then click DWORD Value.
Right-click New Value #1, click Rename, and then type ProcessNameFormat to name the new value.
Right-click ProcessNameFormat, and then click Modify.
In the Data value box, type one of the following values, and then click OK:
1: Disables PID data. This value is the default value.
2: Enables PID data.
Exit Registry Editor.
Warning: Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall the operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk.
Important: If you enable this feature, you may be unable to monitor process-specific information by using third-party utilities or custom-made programs, and this functionality may change at any time in the future without notice.
Hope it helps someone.
I came up with a custom batch script that find the application pool ID, PID, and associates it with the IIS worker process in question. From there, I can manually FIND and REPLACE a generic placeholder in my perfmon configuration file to start collecting for the specific site(s). I can supply some details if there is interest.
I have set the following policy with gpedit in a Windows Server 2008 machine that has IE8:
I have a source that tells me that configuration resides in HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Internet Explorer\Restrictions\NoExtensionManagement -- but that's a lie. There isn't even an Internet Explorer folder under Software\Policies\Microsoft.
Moreover, the same source says the setting is under "Computer Configuration\Network\Internet Explorer\Do Not Allow Users to enable or Disable Add-Ons" on gpedit. As you see above, that isn't true either.
OK, the "source" I'm talking about is the US Government: http://usgcb.nist.gov/usgcb/download_ie8.html -- namely, their IE8 OVAL definitions.
So, where in the registry is that setting?
It is an either/or. The policy can be implemented via the registry OR the GPO. You'll find your GPO where it is set in something like:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{71DA9274-FD7B-4660-A801-B013570D3F5F}Machine\Software\Policies\Microsoft\Internet Explorer\Restrictions
or
HKEY_USERS\S-1-5-21-2090352725-1269969352-1905203885-2959\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\{71DA9274-FD7B-4660-A801-B013570D3F5F}Machine\Software\Policies\Microsoft\Internet Explorer\Restrictions
though the GPO itself is stored on disk, and not the registry ... I think here:
%systemroot%\System32\GroupPolicy
As far as where you'll find various settings in gpedit - it does depend on your version of windows.
After getting hit with some unwanted intrusive piece of software, I couldn't reset the IE8 settings on my Windows XP machine (yes, I know how old that is). Found the problem - the "Control Panel" settings had an additional registry entry in HKLM\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
The zonemap under this registry key had 1803 disabled. That made three different entries for the same value in the registry. It wasn't IE8, it wasn't Group Policies. It was a rogue copy hidden in the HKLM that overrode other settings.
Symptom included that message "some settings controlled by Group Policy ..." Well, who's the group, exactly, on my tablet.
The Microsoft KB182569 is excellent. The only missing data was where to find the "unwanted" copy of zones.
is it possible to check if UAC is enabled with VB6 on win7 and vista?
i know it has to do with reading a value in the registry, i have see .net versions, but i need a vb6 sample code
thanks
DevX.com has an example of how to read the registry using VB6.
You'll have to add this constant: Const HKEY_LOCAL_MACHINE = &H80000002...it's missing from the sample.
You'll want to read the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System key's EnableLUA value. 1 == enabled.
There's also a decent example at freevbcode.com.
I am uninstalling some application and reading the software installation enumeration value from registry.
The problem is after uninstallation it is not changing the registry value untill unless the screen or regedit is not refreshed. after refreshing only i am getting the correct value.
Could some one help me out to refresh the regedit in python codes.
Regards,
upendra
I assume that by "refreshing" the "screen," you mean restarting the computer? Regardless, you can be sure that whatever registry keys you've modified will be correctly updated after the system is restarted. The registry is updated with lazy flush and writer threads, so my guess is that the changes you're making aren't flushed back to the registry immediately, but your question doesn't provide enough information about how you're modifying these registry values for me to be able to propose an alternative solution.
Perhaps more importantly, what are you trying to do here? Are you trying to get your uninstaller to verify that your application has been uninstalled? Why is this necessary? I feel like there has to be a better way than expecting registry edits to be committed and then read back out immediately.
I have kind the same problem. I "install" a python tool and environment and create some system variables in the registry. To refresh the registry I do the following:
def RefreshEnv():
HWND_BROADCAST = 0xFFFF
WM_SETTINGCHANGE = 0x1A
SMTO_ABORTIFHUNG = 0x0002
result = ctypes.c_long()
SendMessageTimeoutW = ctypes.windll.user32.SendMessageTimeoutW
SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0, u'Environment',
SMTO_ABORTIFHUNG, 5000, ctypes.byref(result))
This method is not refreshing the registry like I expected. I still have to open the window to edit the system variables in Windows and just click OK to refresh them. Otherwise my installed tools are crashing with an KeyError while trying to catch the environment variables.
I don't know if the Refresh function abovee will help you (I guess not), but at least it's a try.
You can use either of:
Just restart windows explorer with SysInternal's Process Explorer, or
If you have chocolatey installed, you can just type refreshenv in a PowerShell.
I am modifying the registry key and want to read that values without restarting the system.
I am able to read manually if I refresh the screen (F5 Button), but could you let me know how to capture this through python.