Guess my idea to just write a program to disable win10 upgrades was not a good idea.
Just FYI, the 2nd key is what the group policy does from what I read.
I can't access the LocalMachine Key, I just get a null back.
I did the click run as administrator.
Logged in as administrator.
I really don't want to manually adjust every computer in the office.
Guess Microsoft really tightened up the security which is good.
bool pValue = false;
conststring subKey1 = "SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade";
conststring keyName1 = "AllowOSUpgrade";
conststring keyName2 = "DisableOSUpgrade";
using (var _key = Registry.LocalMachine.OpenSubKey(subKey1, true))
// Set the value for AllowOSUpgrade to false or Dword 0
_key.SetValue(keyName1, 0, RegistryValueKind.DWord);
_key.SetValue(keyName2, 1, RegistryValueKind.DWord);
pValue = true;
catch (Exception ex)
pValue = false;
if (ex.Message == "Attempted to perform an unauthorized operation.")
Console.WriteLine("You must be an adminsitrator to perform this task!");
Console.WriteLine("Right Click on the program and select 'Run as Administrator'");
Console.WriteLine("Press any key to exit");
Console.WriteLine("ERROR: " + ex.Message);
I didn't know that Any CPU had 2 different views of the registry, and calling programs like DSIM.
So I got that part working now for file execution and registry, but even elevating the UAC didn't allow me to edit that value and add a key.
This works great, for all the grids that the edit control showing event is subscribed too, but while tracing another problem I have noticed that when I am getting the row out of the combo box's datasource which is a bindinglist and reading the information to pass back to the database. with the following simplified event below. Each property that I read then fires the selected index event of the combobox.
privatevoid dg_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
DataGridView dgB = sender as DataGridView;
if (dgB.CurrentRow.IsNewRow == true)
LogManager.Instance.Logger("Policy SI").Info("New Row ");
if (e.ColumnIndex == 0)
LogManager.Instance.Logger("Policy SI").Info("Validating Col 1");
string newDescription = string.Empty;
newDescription = e.FormattedValue.ToString();
quoteTemplate = valuablesBinding.FirstOrDefault(p => p.Description == originalDescription || p.Description == policySumInsured.Description);
//Attempted here to deepclone the object from the valuables bindinglist
//quoteTemplate = quoteTemplateNewDescription.DeepClone();
//Here with these 3 lines it will then fire the selectedindexchanged
//event that is on the combobox
policySumInsured.ItemNo = (int)quoteTemplate.ItemNo;
policySumInsured.Description = quoteTemplate.Description;
policySumInsured.Section = quoteTemplate.Section;
if (e.ColumnIndex == 1)
//Other validation routine here
Hopefully this all makes and sense and someone could possibley shed some light on why it keeps firing the cb_selectedIndexChanged event.
Every day, thousands of innocent plants are killed by vegetarians.
So basically, you want us to write your code for you? If we provide assistance, shouldn't you be able to do that by yourself?
There are many ways, and they all depend on what you are trying to achieve. You could use FTP. You can use shared paths to copy to (a really bad idea). You can use something like TCP with a client/server infrastructure. Without knowing more about what you are trying to copy and what the constraints are, it's hard to be any more specific than that.
With some assistance I will be able to do it myself.
With this below Line of code(in vb.net) I am able to copy files from one server to another.The issue is that this copy all Files that are in the source directory folder to destination folder while i just want specific files with extension .txt
below is the code am using
My.Computer.FileSystem.CopyDirectory("\\220.127.116.11\c$\Txxx\", "\\18.104.22.168\D$\d", True)
Is there a way I can be able to just copy only text files and after copying I move the files copied to a backup folder and then delete them
You'd effectively need two operations. The first one is to use Directory.GetFiles[^] to get all the files in a particular directory (or directory structure) that have the .txt extension. Then you would need to iterate over each filename and use File.Copy[^] to copy the files over.
I'm struggling with navigation in asp.net mvc and URLs.
When you are visiting your profile at facebook, the url is facebook.com/yourusername.
At your profile there is a menu with the following links: Timeline, About, Friends etc.
When you click on one of these links, for example Photos, the URL is changed to facebook.com/yourusername/Photos, and the photos are rendered. The menu described above are still there, and so also the profile picture and the cover picture. Its like a partial view has rendered viewing the photos.
I want to accomplish this effect in my project, but I don't know how to do it. I have tried to do it with Partial view but the problem is that the URL is not changed when the partial view is rendered.
Anyone can help me with this? How should I structure it?
No I am not, do you have a suggestion on another way I can check?
The code under the Exception snapshot, always has the same error message with the Parameter is not valid at
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.Image.FromStream(Stream stream)
at Updator.PictureUpdater.btnViewPicture_Click(Object sender, EventArgs e) in c:\Users\xxxx\Documents\Visual Studio 2012\Projects\Updator\Updator\Form1.cs:line 245
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Updator.Program.Main() in c:\Users\xxx\Documents\Visual Studio 2012\Projects\Exchange Picture Updator\Updator\Program.cs:line 19
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String args)
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
I figured it out, I had to build my own byte array and not use memory stream. Memory stream was corrupting the file and making it an additional 28 bytes. I'm not sure why this wasn't on the internet, as it seems 100's of people encounter this?
Thanks for pointing me in the right direction.
byte imgBytes = null;
List<byte> imgBytesList = new List<byte>();
object imgObj = null;
Image img = null;
foreach (PSObject obj in exResults)
imgObj = obj.Properties["PictureData"].Value;
foreach (byte byt in (dynamic)imgObj)
imgBytes = imgBytesList.ToArray();
using (var ms = new MemoryStream(imgBytes))
img = Image.FromStream(ms);
pbxDisplayPicture.Image = img;
I have an application that uses a COM object to make a connection to an application. I need to make sure that when my application ends that I call the EndSession and CloseConnection methods of this COM object. I was reading this article: Implementing IDisposable and the Dispose Pattern Properly[^] as I think this is what I would need to do to make sure my closing code always gets called, but it doesn't seem to happen when I stop debugging. The application that I am connecting to still thinks my program is connected. It seems like when I stop debugging (or if I have a program crash, that the Dispose methods don't get called. I also tried to add a Finalizer but that causes a System.Runtime.InteropServices.InvalidComObjectException stating that the COM object that has been separated from it's underlying RCW cannot be used.
protectedvirtualvoid Dispose(bool disposing)
if (_Session != null) // _Session is the COM object.
_Session.EndSession(); // These are the COM functions to close and end the
_Session.CloseConnection(); // session that must be called, but this is where I
_Session = null; // get the InvalidComObjectException.
disposed = true;
~SessionConnection() // This was added, which seems to be the root cause of the COM exception
I'm not sure what is the best way to ensure that the EndSession and CloseConnection methods of my COM object get called even if my program crashes or I stop debugging.
When you launch the code from inside Visual Studio, it's launched, the debugger is attached and you debug on your merry way. If you hit Stop inside Visual Studio, your code is stopped, wherever it is, and removed from memory. Your Dispose code never gets executed.
The only way to make sure it does is if you exit your application as a user would, gracefully.
That's what I was going to say!
The only thing I'd add is that the same thing will happen if you use Task Manager to kill the process. So if this is causing a problem with "Stop debugging" it'll also cause the same problem if the user terminates the app.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
Last Visit: 31-Dec-99 18:00 Last Update: 28-May-16 22:28