void createStartMenu() { string StartMenu = var_data.getStartMenu() + "\\" + InfraSoftwareServer.nameServer + " Server"; if (!Directory.Exists(StartMenu)) { Directory.CreateDirectory(StartMenu); } // Program link { string shortcut = StartMenu + "\\Server.lnk"; if (System.IO.File.Exists(shortcut)) { System.IO.File.Delete(shortcut); } WshShellClass WshShell = new WshShellClass(); IWshShortcut MyShortcut = (IWshShortcut)WshShell.CreateShortcut(shortcut); MyShortcut.TargetPath = var_data.pathDir + @"\" + InfraSoftwareServer.nameServer + ".exe"; MyShortcut.IconLocation = var_data.pathDir + @"\" + InfraSoftwareServer.nameServer + ".exe"; MyShortcut.WorkingDirectory = var_data.pathDir; MyShortcut.Save(); } // Uninstall link { string shortcut = StartMenu + "\\uninstall.lnk"; if (System.IO.File.Exists(shortcut)) { System.IO.File.Delete(shortcut); } WshShellClass WshShell = new WshShellClass(); IWshShortcut MyShortcut = (IWshShortcut)WshShell.CreateShortcut(shortcut); string path = System.Environment.GetEnvironmentVariable("COMMONPROGRAMFILES") + "\\" + InfraSoftwareServer.nameServer; MyShortcut.TargetPath = path + "\\ServerSetup.exe"; MyShortcut.WorkingDirectory = path; MyShortcut.IconLocation = path + "\\ServerSetup.exe"; MyShortcut.Save(); } }
//Получаем данные из StartMenu - возвращает список (List) файлов(Prgrm) public async Task <List <Prgrm> > GetFilesListFromStartMenu() { return(await Task.Run(() => { List <Prgrm> Files = new List <Prgrm>(); //Создаем список программ которые будем возвращать string[][] AllUsersAndCurrentUserPATHs = new string[2][]; //Создаем массив, который будет содержать пути к двум папкам автозапуска (для CurrentUSer и AllUsers), а на втором уровне пути к файлам этих веток автозапуска AllUsersAndCurrentUserPATHs[0] = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Startup)); //Current User AllUsersAndCurrentUserPATHs[1] = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup)); //All Users for (int i = 0; i < AllUsersAndCurrentUserPATHs.Count(); i++) //Перебираем эти пути к этим веткам { foreach (string filepath in AllUsersAndCurrentUserPATHs[i]) //Перебираем пути к файлам текущей ветки { FileInfo fileinfo = new FileInfo(filepath); if (fileinfo.Extension == ".lnk") //Если расширение текущего файла явл '.lnk' { WshShell shell = new WshShell(); IWshShortcut link = (IWshShortcut)shell.CreateShortcut(filepath); //Создаем эземпляр ярлыка приводя его к типу IWshShortcut //Задаем переменные для св-в Prgrm string FilePath = link.TargetPath; string FileName = fileinfo.Name; string FileParams = link.Arguments; BitmapFrame Icon = GetIcon(FilePath); //Получаем Иконку string StartupType = "Start Menu - Current User"; if (i == 1) { StartupType = "Start Menu - All Users"; } //Если обрабатываемая ветка вторая - то значит это тип AllUSers //Cоздаем экземпляр prgrm для добавления Prgrm prgrm = new Prgrm() { Icon = Icon, FileName = FileName, FilePath = FilePath, CmdlineParams = FileParams, StartupType = StartupType }; //Заполняем информацию о сертификатах и компании из сертификата либо из атрибутов файла при отсутвии сертификата prgrm = FillCertData(prgrm); //Формируем список екземпляров Prgrm для return, заполняя его полученными значениями Files.Add(prgrm); } } } return Files;//Возвращаем список файлов })); }
private bool SetLnk(ref bool isLnkDirectory, ref string resolvedLnkPath) { bool handled = false; resolvedLnkPath = LnkHelper.GetResolvedFileName(TargetFilePath); if (LnkHelper.IsDirectory(resolvedLnkPath)) { Icon = IconReader.GetFolderIcon(TargetFilePath, IconReader.FolderType.Open, true); handled = true; isLnkDirectory = true; } else if (string.IsNullOrEmpty(resolvedLnkPath)) { Log.Info($"Resolve *.LNK '{TargetFilePath}' has no icon"); #warning [Feature] Resolve network root #48, start here } else { IWshShell shell = new WshShell(); IWshShortcut lnk = shell.CreateShortcut(TargetFilePath) as IWshShortcut; Arguments = lnk.Arguments; WorkingDirectory = lnk.WorkingDirectory; string iconLocation = lnk.IconLocation; if (iconLocation.Length > 2) { iconLocation = iconLocation.Substring(0, iconLocation.Length - 2); if (System.IO.File.Exists(iconLocation)) { try { Icon = Icon.ExtractAssociatedIcon(iconLocation); handled = true; } catch (ArgumentException ex) { Log.Warn($"iconLocation:'{iconLocation}'", ex); } } } TargetFilePath = resolvedLnkPath; } SetText(Path.GetFileNameWithoutExtension(TargetFilePathOrig)); return(handled); }
private static void Install() { string fupath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FuEQ"); string exeName = Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName); if (!Directory.Exists(fupath)) { Directory.CreateDirectory(fupath); if (!Directory.Exists(fupath)) { MessageBox.Show("Unable to create FuEQ folder, install failed"); return; } } else { if (fupath != Environment.CurrentDirectory) { System.IO.File.Delete(Path.Combine(fupath, exeName)); } } // copy self to fupath System.IO.File.Copy(Path.Combine(Environment.CurrentDirectory, exeName), Path.Combine(fupath, exeName)); // setup logs folder Directory.CreateDirectory(Path.Combine(fupath, LogFolder)); // create desktop shortcut string shortcutpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "FuEQ.lnk"); WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutpath); shortcut.Description = "FU Raid Tool Config"; // The description of the shortcut //shortcut.IconLocation = Path.Combine(fupath, exeName); // The icon of the shortcut (doesnt seem needed) shortcut.TargetPath = Path.Combine(fupath, exeName); // The path of the file that will launch when the shortcut is run shortcut.Save(); // if no existing config file make one if (!System.IO.File.Exists(Path.Combine(fupath, exeName + ".config"))) { BuildEmptyConfigFile(Path.Combine(fupath, exeName + ".config")); } // start a new instance of this app out of the new folder (no params) Process.Start(Path.Combine(fupath, exeName)); // close the current instance Process.GetCurrentProcess().Kill(); }
private void CreateShortcut(string shpath, string CMpath, string Game, string Gamepath, string GameID, string icopath) { WshShell shell = new WshShell(); object shDesktop = (object)"Desktop"; string shortcutAddress = shpath + @"\" + Game + ".lnk"; IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress); shortcut.Description = "Created by Shortcut-Generator for CEMU"; shortcut.TargetPath = CMpath + @"\cemu.exe"; shortcut.WorkingDirectory = CMpath; if (checkBox1.Checked) { if (Directory.Exists(icopath)) { string ico = icopath + @"\" + GameID + @".ico"; if (System.IO.File.Exists(ico)) { shortcut.IconLocation = ico; } else { NoIco.Add(Game + " [" + GameID + "]\r\n"); } } else { MessageBox.Show("Your Icon-Path hasn't been found?"); DialogResult dialogResult = MessageBox.Show("Do you want to select a new one?\r\n(Alternatively Icons are unavailable)", "Shortcut-Generator", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Back_Click(new object(), new EventArgs()); } else if (dialogResult == DialogResult.No) { MessageBox.Show("Continuing without Icons!"); } } } string args = "-g \"" + Gamepath + "\""; if (checkBox1.Checked) { args += " -f"; } shortcut.Arguments = args; shortcut.Save(); reset(); //MainWindow_Load(new object(), new EventArgs()); }
public static string ExtrairCaminhoReal(String atalho) { if (System.IO.File.Exists(atalho)) { WshShell shell = new WshShell(); //Create a new WshShell Interface IWshShortcut link = (IWshShortcut)shell.CreateShortcut(atalho); //Link the interface to our shortcut return(link.TargetPath); } else { return(String.Empty); } }
public static void CreateShortcut(Server server, string path) { WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(path); shortcut.Description = $"Switch to {server.ServerName} and start osu!"; if (server.Icon != null) { shortcut.IconLocation = m_iconCacheFolder + $@"\{server.ServerName}.ico"; } shortcut.TargetPath = "cmd"; shortcut.Arguments = $"/c call \"{Application.ExecutablePath}\" \"{server.ServerName}\""; shortcut.Save(); }
public void CreateShortcut(string lnkFileName, string TargetPath, string Description, string WorkingDirectory) { //DesktopDirectory string shortcutPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + " " + "\\" + lnkFileName + ".lnk"; WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath); shortcut.TargetPath = TargetPath; //TargetPath 設置你的程式的位置。 shortcut.WorkingDirectory = WorkingDirectory; //System.Environment.CurrentDirectory;//WorkingDirectory 工作目錄。 shortcut.WindowStyle = 1; //WindowStyle :1、為 normal ,3、Maximized,7、Minimized。 shortcut.Description = Description; shortcut.Save(); //最後一定要Save,否則只 CreateShortcut 是創建不出 快捷方式的。 }
public static void CreateDesktopShortcut() { object shDesktop = (object)"Desktop"; WshShell shell = new WshShell(); string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\" + Application.ProductName + ".lnk"; if (!System.IO.File.Exists(shortcutAddress)) { IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress); shortcut.TargetPath = Application.ExecutablePath; shortcut.WorkingDirectory = Application.StartupPath; shortcut.Save(); } }
public static void CreateStartupShortcut() { try { IWshShortcut shortcut = (IWshShortcut)(new WshShell()).CreateShortcut(GetStartupPath()); shortcut.Description = ((AssemblyDescriptionAttribute)assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), true)[0]).Description; shortcut.TargetPath = assembly.Location; shortcut.Save(); } catch { throw; } }
public void CreateLink(string linkName, string targetPath, string args = "") { object shDesktop = (object)"Desktop"; WshShell shell = new WshShell(); string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + "\\" + linkName + ".lnk"; IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress); shortcut.Arguments = args; shortcut.Description = "Link per consegna compito"; shortcut.WorkingDirectory = Path.GetDirectoryName(targetPath); //shortcut.Hotkey = "Ctrl+Shift+N"; shortcut.TargetPath = targetPath; shortcut.Save(); }
/// <summary> /// 获取快捷方式的目标文件路径-用于判断是否已经开启了自动启动 /// </summary> /// <param name="shortcutPath"></param> /// <returns></returns> private string GetAppPathFromQuick(string shortcutPath) { //快捷方式文件的路径 = @"d:\Test.lnk"; if (System.IO.File.Exists(shortcutPath)) { WshShell shell = new WshShell(); IWshShortcut shortct = (IWshShortcut)shell.CreateShortcut(shortcutPath); return(shortct.TargetPath); } else { return(""); } }
/// <summary> /// Creates a QuickSwitch shortcut at the given location for the given server /// </summary> /// <param name="file">The path to the .lnk file</param> /// <param name="server">The server the shortcuts lets you switch to</param> public static void CreateShortcut(string file, Server server) { WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(file); shortcut.Description = $"Switch to {server.ServerName}"; if (server.Icon != null) { shortcut.IconLocation = Paths.IconCacheFolder + $@"\{server.UID}.ico"; } shortcut.TargetPath = "cmd"; shortcut.Arguments = $"/c call \"{Application.ExecutablePath}\" \"{server.UID}\""; shortcut.Save(); }
/// <summary> /// Add a shortcut to the startup menu, to load the application on login /// </summary> public static void Add() { String startupFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); WshShell shell = new WshShell(); String shortCutLinkFilePath = Path.Combine(startupFolderPath, Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().GetName().Name) + ".lnk"); IWshShortcut windowsApplicationShortcut = (IWshShortcut)shell.CreateShortcut(shortCutLinkFilePath); windowsApplicationShortcut.Description = String.Format("{0} - Music player based on Leap Motion Controller", Application.ProductName); windowsApplicationShortcut.WorkingDirectory = Application.StartupPath; windowsApplicationShortcut.TargetPath = Application.ExecutablePath; windowsApplicationShortcut.Save(); }
// Install shell:startup public static void installShellStartup(string path) { // Create shortcut string[] data = getAutorunData(path); string shellStartup = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\"; WshShell wsh = new WshShell(); IWshShortcut shortcut = wsh.CreateShortcut(shellStartup + data[1] + ".lnk") as IWshShortcut; shortcut.Arguments = ""; shortcut.TargetPath = data[0]; shortcut.WorkingDirectory = Path.GetDirectoryName(data[0]); shortcut.Save(); core.Exit("Installed " + data[1] + " to autorun. Method with shell:startup directory", output); }
public static void CreateShortcut(string destination) { // Create a WshShell instance through which to access the // functionality of the Windows shell. WshShell wshShell = new WshShell(); // Assemble a fully qualified name that places the Notepad.lnk // file in the specified destination folder. You could use the // System.Environment.GetFolderPath method to obtain a path, but // the WshShell.SpecialFolders method provides access to a wider // range of folders. You need to create a temporary object reference // to the destination string to satisfy the requirements of the // Item method signature. object destFolder = (object)destination; string fileName = Path.Combine( (string)wshShell.SpecialFolders.Item(ref destFolder), "Notepad.lnk" ); // Create the shortcut object. Nothing is created in the // destination folder until the shortcut is saved. IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut(fileName); // Configure the fully qualified name to the executable. // Use the Environment class for simplicity. shortcut.TargetPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.System), "notepad.exe" ); // Set the working directory to the Personal (My Documents) folder. shortcut.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Provide a description for the shortcut. shortcut.Description = "Notepad Text Editor"; // Assign a hotkey to the shortcut. shortcut.Hotkey = "CTRL+ALT+N"; // Configure Notepad to always start maximized. shortcut.WindowStyle = 3; // Configure the shortcut to display the first icon in Notepad.exe. shortcut.IconLocation = "notepad.exe, 0"; // Save the configured shortcut file. shortcut.Save(); }
public static void CreateShortcut( string linkFileFullName, string targetPath, string description = null, string iconLocation = null) { WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(linkFileFullName); shortcut.TargetPath = targetPath; shortcut.WorkingDirectory = Path.GetDirectoryName(targetPath); shortcut.WindowStyle = 1; shortcut.Description = description; shortcut.IconLocation = string.IsNullOrWhiteSpace(iconLocation) ? targetPath : iconLocation; shortcut.Save(); }
public static IWshShortcut GetShortcutInfo(string linkPathName) { if (System.IO.File.Exists(linkPathName)) { // WshShellClass shell = new WshShellClass(); IWshRuntimeLibrary.WshShell shell = new WshShell(); //Create a new WshShell Interface IWshShortcut link = (IWshShortcut)shell.CreateShortcut(linkPathName); //Link the interface to our shortcut return(link); //AAAAAAA //return link.TargetPath; //Show the target in a MessageBox using IWshShortcut } return(null); }
/// <summary> /// 在桌面上创建快捷方式 /// </summary> public void CreateShortcut() { WshShell wsh = new WshShell(); string DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\"; IWshShortcut iss = (IWshShortcut)wsh.CreateShortcut(DesktopPath + data.Name + ".lnk"); iss.Description = data.Name; iss.TargetPath = data.Path; iss.WindowStyle = 1; iss.WorkingDirectory = ""; iss.Save(); }
private static void CreateShortcut(string shortcutPath, string targetPath, string iconPath = null) { WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath); shortcut.TargetPath = targetPath; if (iconPath != null) { shortcut.IconLocation = iconPath; } shortcut.Save(); }
static void CreateStartupShortcut() { string startupFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup); WshShell shell = new WshShell(); string shortcutAddress = startupFolder + @"\HRDSQTrayShortcut.lnk"; IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress); shortcut.Description = "A startup shortcut. If you delete this shortcut from your computer, HRDSQTray.exe will not launch on Windows Startup"; // set the description of the shortcut shortcut.WorkingDirectory = Application.StartupPath; /* working directory */ shortcut.TargetPath = Application.ExecutablePath; /* path of the executable */ // optionally, you can set the arguments in shortcut.Arguments // For example, shortcut.Arguments = "/a 1"; shortcut.Save(); }
private static IWshShortcut GetLnkTarget(string lnkPath) { if (File.Exists(lnkPath)) { WshShell shell = new WshShell(); //Create a new WshShell Interface IWshShortcut link = (IWshShortcut)shell.CreateShortcut(lnkPath); //Link the interface to our shortcut return(link); } else { return(null); } }
public void CreateShortcut(string ShortcutDirectory) { var wsh = new IWshShell_Class(); IWshShortcut shortcut = wsh.CreateShortcut(ShortcutDirectory + "\\Igloo.lnk") as IWshRuntimeLibrary.IWshShortcut; shortcut.Arguments = ""; shortcut.TargetPath = installer.DefaultDirectory + @"\Igloo Browser.exe"; // not sure about what this is for shortcut.WindowStyle = 1; shortcut.Description = "A web browser made by MoonByte"; shortcut.WorkingDirectory = installer.DefaultDirectory; shortcut.IconLocation = installer.DefaultDirectory + @"\icon.ico"; shortcut.Save(); }
public static string AbsolutePath(string shotcutPath) { IWshShell shell = new WshShell();// 바로가기 절대경로 try { IWshShortcut link = (IWshShortcut)shell.CreateShortcut(shotcutPath); return(link.TargetPath); } catch (Exception ex) { return(string.Empty); } }
private void InstallShortcuts(string path) { Logger.Info($"Adding SRS Shortcut"); string executablePath = Path.Combine(path, "SR-ClientRadio.exe"); string shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms), "DCS-SRS Client.lnk"); WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath); shortcut.Description = "DCS-SimpleRadio Standalone Client"; shortcut.TargetPath = executablePath; shortcut.WorkingDirectory = path; shortcut.Save(); }
private void createShortcut(string app) { string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); WshShell shell = (WshShell)Activator.CreateInstance(System.Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"))); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(deskDir + "\\Subifier.lnk"); shortcut.TargetPath = app; string icon = app.Replace('\\', '/'); shortcut.Description = "Launch Subifier"; shortcut.IconLocation = icon; shortcut.Save(); }
// boolean variable "install" determines whether the link should be there or not. // Update the folder by creating or deleting the link as required. /// <summary> /// Update the specified folder by creating or deleting a Shell Link if necessary /// </summary> /// <param name="DirectoryPath">The full path of the directory in which the link will reside</param> /// <param name="TargetPathName">The path name of the target file for the link</param> /// <param name="LinkPathName">The file name for the link itself or, if a path name the directory information will be ignored.</param> /// <param name="Create">If true, create the link, otherwise delete it</param> public static void Update(string DirectoryPath, string TargetPathName, string LinkPathName, bool Create) { // Get some file and directory information DirectoryInfo SpecialDir = new DirectoryInfo(DirectoryPath); // First get the filename for the original file and create a new file // name for a link in the Startup directory // FileInfo OriginalFile = new FileInfo(LinkPathName); string NewFileName = SpecialDir.FullName + "\\" + OriginalFile.Name + ".lnk"; FileInfo LinkFile = new FileInfo(NewFileName); if (Create) // If the link doesn't exist, create it { if (LinkFile.Exists) { return; // We're all done if it already exists } //Place a shortcut to the file in the special folder try { // Create a shortcut in the special folder for the file // Making use of the Windows Scripting Host WshShell shell = new WshShell(); IWshShortcut link = (IWshShortcut)shell.CreateShortcut(LinkFile.FullName); link.TargetPath = TargetPathName; link.Save(); } catch { MessageBox.Show("Unable to create link in special directory: " + NewFileName, "Shell Link Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else // otherwise delete it from the startup directory { if (!LinkFile.Exists) { return; // It doesn't exist so we are done! } try { LinkFile.Delete(); } catch { MessageBox.Show("Error deleting link in special directory: " + NewFileName, "Shell Link Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//get the original exe file Location instead of the shortcut //TODO: update 1: //Get the "start in" location //get the parameters //change its class to DMShortcutitem class public static string GetOriginalFileURL(string Location) { if (System.IO.File.Exists(Location)) { // WshShellClass shell = new WshShellClass(); WshShell shell = new WshShell(); IWshShortcut link = (IWshShortcut)shell.CreateShortcut(Location); return(link.TargetPath); } else { return(""); } }
/// <summary> /// Creates a shortcut programatically, used for testing /// </summary> /// <param name="file"></param> /// <param name="target"></param> /// <param name="arguments"></param> /// <returns></returns> public static bool CreateLink(string file, string target, string arguments) { try { IWshShell wsh = new WshShellClass(); IWshShortcut sc = (IWshShortcut)wsh.CreateShortcut(file); sc.WorkingDirectory = API.Phantom.libraryPath; sc.TargetPath = Path.Combine(API.Phantom.libraryPath, target); sc.Arguments = arguments ?? ""; sc.Save(); } catch { } return(false); }
public void CreateShortCut() { string strFullPath = Application.ExecutablePath; string strFileName = System.IO.Path.GetFileNameWithoutExtension(strFullPath); string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop);//得到桌面文件夹 WshShell shell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(DesktopPath + "\\" + strFileName + ".lnk"); shortcut.TargetPath = System.Reflection.Assembly.GetExecutingAssembly().Location; shortcut.Arguments = "";// 参数 shortcut.WorkingDirectory = System.Environment.CurrentDirectory; shortcut.WindowStyle = 1; shortcut.Save(); }
private static bool IsUserDataDirArgWithUserProfile(IWshShortcut link, string userProfileName) { var argUserDataDirUserProfileNameMatches = false; // split by chrome args identifier var linkArgsSplit = link.Arguments.Split(new[] { SystemDetails.ChromeExeArgId }, StringSplitOptions.RemoveEmptyEntries); // for each chrome arg foreach (var arg in linkArgsSplit) { // split into arg id & value var argSplit = arg.Split('='); // if arg id is chrome user data dir arg if (argSplit[0].Equals(SystemDetails.ChromeUserDataDirArg)) { // see the the arg value is a dir try { var argDir = new DirectoryInfo(argSplit[1].Replace("\"", "")); // chrome user data dir? if (argDir.Parent != null) { if (argDir.Parent.FullName.Equals(SystemDetails.ChromeUserDataDir.FullName)) { // if the dir name is the chrome user profile name we are looking for... if (argDir.Name.Equals(userProfileName)) { // found it, and ... argUserDataDirUserProfileNameMatches = true; // ... we don't need to look at the other args! break; } } } } catch (Exception e) { Console.WriteLine(e); } } } return argUserDataDirUserProfileNameMatches; }