public static ShareReturnCode Create(string machineName, string shareName, string path, string description) { try { path = Path.GetFullPath(path); const string methodName = "Create"; //todo: This only creates read only shares var parameters = new object[] { path, // Path shareName, // Name 0x0, // Type null, // MaximumAllowed description, // Description null, // Password null // Win32_SecurityDescriptor Access }; return((ShareReturnCode)WmiHelper.InvokeStaticMethod(machineName, CLASSNAME, methodName, parameters)); } catch { return(ShareReturnCode.UnknownFailure); } }
//private char NULL_VALUE = char(0); public static ServiceReturnCode Create(string machineName, string serviceName, string serviceDisplayName, string serviceLocation, ServiceStartMode startMode, string userName, string password, string[] dependencies) { if (userName != null && userName.IndexOf('\\') < 0) { userName = "******" + userName; } try { const string methodName = "Create"; var parameters = new object[] { serviceName, // Name serviceDisplayName, // Display Name serviceLocation, // Path Name | The Location "E:\somewhere\something" Convert.ToInt32(ServiceType.OwnProcess), // ServiceType Convert.ToInt32(ErrorControl.UserNotified), // Error Control startMode.ToString(), // Start Mode false, // Desktop Interaction userName, // StartName | Username password, // StartPassword |Password null, // LoadOrderGroup | Service Order Group null, // LoadOrderGroupDependencies | Load Order Dependencies dependencies // ServiceDependencies }; return((ServiceReturnCode)WmiHelper.InvokeStaticMethod(machineName, CLASSNAME, methodName, parameters)); } catch { return(ServiceReturnCode.UnknownFailure); } }