I'm writing this program that will need to access the registry to pull some info on the machine. It should always be run by someone in the Local Admin group, and it will be used on Server 2003 and 2008 machines. Basically it's been working fine for the most part on the box that I'm mainly writing it on, as well as my test 2003 and 2008 servers. The problem is, when I get on my laptop, which is running Windows 7, I cannot seem to use it for testing as I'm getting errors when trying to read or write the registry below HKEY_LOCAL_MACHINE\SOFTWARE.
I'm logged in as a user who is a local admin, and I can run Regedit to create a key, such as test9999. If I use the following it will always come back null.
RegistryKey testKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\test9999");
I've tried dropping the subkey and SOFTWARE will return, but I haven't been able to get anything below that.
I'm using MS VC# Express and I've tried running it "as Administrator" as well as trying to run the .exe's the same way, but it still continues to return null for anything below Software. What am I missing?
Turns out registry redirection behavior for 32 bit processes running on 64 bit Windows was changed in Windows 7 and Windows 2008 R2, which may explain why it works on Windows 2008 (not R2 I assume) and not on Windows 7.
Read more about it here: http://msdn.microsoft.com/en-us/library/aa384232(v=vs.85).aspx
Related
I need to take backup of windows data and its settings using C# code.
In order to achieve the goal I am running the following command:
Wbadmin start backup
SOURCE of the command
Problem:
This command is not working with all versions of Windows.
Request
Is there any other reliable way to take windows data and settings backup.
Wbadmin works on:
Windows Vista
Windows Server 2008
Windows 7
Windows 8
Windows 10
Windows Server 2008 R2
Windows Server 2012
That's a pretty standard recommended solution. What are you running into issues with beyond that?
You should be able to use something like Scenario #2 from:
https://technet.microsoft.com/en-us/library/cc742083(v=ws.11).aspx
wbadmin start backup –backupTarget:d: -include:g\folder1,h:\folder2 –systemstate -vsscopy
It would also be a good idea to take note of the syntax section
Syntax for Windows Vista and Windows Server 2008:
wbadmin start backup
[-backupTarget:{<BackupTargetLocation> | <TargetNetworkShare>}]
[-include:<VolumesToInclude>]
[-allCritical]
[-noVerify]
[-user:<UserName>]
[-password:<Password>]
[-noinheritAcl]
[-vssFull]
[-quiet]
Syntax for Windows 7 and Windows Server 2008 R2 and later:
Wbadmin start backup
[-backupTarget:{<BackupTargetLocation> | <TargetNetworkShare>}]
[-include:<ItemsToInclude>]
[-nonRecurseInclude:<ItemsToInclude>]
[-exclude:<ItemsToExclude>]
[-nonRecurseExclude:<ItemsToExclude>]
[-allCritical]
[-systemState]
[-noVerify]
[-user:<UserName>]
[-password:<Password>]
[-noInheritAcl]
[-vssFull | -vssCopy]
[-quiet]
You might have to detect the OS and run wbadmin start systemstatebackup in some scenarios. As you might notice, the systemState flag is missing from Windows Vista and Windows Server 2008. It's also important to note that wbadmin start systemstatebackup does not work on Windows 10, you will be greeted with the following message:
Warning: The DELETE SYSTEMSTATEBACKUP command is not supported in this version of Windows.
The operation ended before completion.
A legacy program coded in Delphi 7 and accessing an Interbase 3 database using C# was moved from Windows 7 64 Bit to Windows Server 2012 64 Bit.
Now, when we run the program, it triggers the C# code, which accesses the IB 3 database. This triggers this error: System.InvalidOperationException: The 'LCPI.IBProvider' provider is not registered on the local machine.
Looking online, I'm not sure which LCPI.IBProvider to register. (It seems to have already been registered on the Windows 7 machine.)
We are unable to update the Interbase 3 database without jeopardizing our work.
Any thoughts / suggestions?
Please contact the ibprovider support , it might be that you need to register it on that machine
http://www.ibprovider.com/eng/download.html
We have a automated printing service running as System account printing web urls.
The idea is using WebBrowser to load page and call Print upon it finished loading.
This works fine on Server 2003 , 2008r2 etc but does not work on Server 2012 ONLY IF it was running as a service. running as a console application works fine.
The problem:
It would load web pages fine and would call Print() , Print() will return but nothing gets printed on the default printer: no print job at all.
I thought it would be account problem so I tried to run service as the same logged on user but still does not work, if that user run application as console app then it would work fine. So default printer and user account get ruled out.
I don't think it is a code problem (it must be though) as it works for older Windows versions running as service.
It seems something fundamental got changed for a service process in server 2012.
Update 1. It may relates to How do I print an HTML document from a web service?
However it works fine for me prior server 2012.
Update 2. It does not work even the whole print happens in a separate process, i.e. my service launches a process to do print, it does not work either. Everything works fine if I run same code in console mode. It is definitely not a threading problem but rather something deep in server 2012.
Now the questions are:
What is changed? Why it stopped working?
At http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/fdcfa0fa-50aa-4a61-be79-5b4c8f65fbf7/ we see that this was reported to Microsoft and confirmed as a bug in Windows 8 and Windows Server 2012.
This bug is triggered when trying to print from a 32bit process in non-standard user session (like e.g. a service).
According to Microsoft, this a bug was resolved in Windows 8.1 and Windows Server 2012 R2. However, we could still reproduce it on Windows 8.1.
On the same site, a workaround is given by Microsoft. This workaround solved the problem for us on Windows 8.1. It probably also works on Windows 8 and Windows Server 2012.
The workaround goes as follows:
Open Regedit and go to HKEY_CLASSES_ROOT\CLSID{BA7C0D29-81CA-4901-B450-634E20BB8C34}
Check the value of the "AppID" Registry Entry. In our case this was {AA0B85DA-FDDF-4272-8D1D-FF9B966D75B0}
Now go to HKEY_CLASSES_ROOT\AppID{AA0B85DA-FDDF-4272-8D1D-FF9B966D75B0} (or the respective value you found on your system)
Under this registry key, delete the entries with the name "AccessPermission", "LaunchPermission" and "RunAs"
Since this is a bug in Windows, you cannot fix it in your code. The workaround might have side effects, but we haven't seen any so far in our scenario.
We have an application that requires to be continously run but it can't run as a service so we run it in Windows 2003 console session. After migration to Windows 2008 and with the session 0 isolation, the GPO causes the session to teminate after the session is idle for 30 minutes.
I wrote a little C# application to simulate key press using sendkeys.send and sendwait but the remote desktop session still gets connected. Any source code or idea to keep the session permentantly active other than changing the GPO as this isn't possible for the time being?
I think there are prob two options you could look at for obtaining the desired effect.
1) SrvAny.exe - this is a tool provided by Microsoft, that will take any exe and run it from the services control panel. While there is no version that officially supports server 2008, the version that works on server 2003 works just fine. I've used it to run dropbox has a service in the past.
Here is a tutorial that does something similar with dropbox Dropbox as a service on server 2008
2) Write a stub application that will run as a service and do nothing more than launch the exe from the vendor.
I realize this is not what you asked persay, but it would give you the desired effect.
I'm getting desperate so was hoping someone could help. We've re-written an old VB app that uses CDOEXM to create mailboxes in Exchange 2003. The new C# code is very similar and looks like this:
CDOEXM.IMailboxStore mailbox;
mailbox = (IMailboxStore)user.NativeObject;
mailbox.CreateMailbox(homeMDB);
user.CommitChanges();
The server running the code needed to have Exchange Management Tools installed for it to work (that installs the CDOEXM libraries that we require)
This works fine on XP, but we're also moving to Windows 2008 64bit servers, and I have been unable to install Exchange Management Tools on here because it says there's a compatibility issue.
Can anyone recommend a way around this? As I said, we're getting desperate because this is going to prevent a production release if we can't solve it, so would really appreciate some help.
Thanks
EDIT: incidentally I manually registered the CDOEXM dlls as a bit of a bodge, and I now get this error:
Problem creating mailboxSystem.ArgumentException: Value does not fall within the expected range.
at CDOEXM.IMailboxStore.CreateMailbox(String HomeMDBURL)
The homeMDBURL I am using is a valid one as far as I can tell though
I don't think CDOEXM is supported on Windows 2008. What about having a Windows 2003 Server around which hosts a WebService that does the mailbox creation stuff?
Another option is to create the mailbox without using CDOEXM. Note that this approach is totally unsupported by Microsoft. But if you populate enough properties (I don't know them all out of my head) like homeMDB and others, the Recipient Update Service (RUS) will create the mailbox on its next run. If I recall it correctly, the RUS runs every two minutes by default.
Btw, you did run your C# program as a 32bit process, right?