Running Firefox with Youtube causes UAC for flash player to appear - c#

I am trying to play a YouTube video in Firefox (portable), but when I run it as follows,
the UAC appears for the flash player asking if you want this program to make changes to the computer. When I run it from the commandline, it does not do this. How can I prevent this from happening? I probably should ask this as separate question, but can somebody tell why it never minimizes.
Process proc = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(#"C:\FirefoxPortable\FirefoxPortable.exe", #"http://www.youtube.com/watch?v=1pSyYhRYeIM");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
proc.StartInfo = startInfo;
proc.Start();

Try running your application as administrator.
also, i love the video thanks for that +1

Related

Being prompted for uac using c# process

I am trying to run an exe inside a console application. I am being prompted for UAC to enter admin credentials. The thing is i only have read and execute permissions. I cannot give full permissions as it is on a server.
using (Process process = new Process())
{
process.StartInfo.Verb = "runas";
process.StartInfo.FileName = ImgToDjvuPath;
process.StartInfo.Arguments = string.Format("\"{0}\" -profile \"{1}\" \"{2}\" \"{3}\"", ImgToDjvuPath, "fine200up", localNewDjvuFile, localNewDjvuFile);
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.WaitForExit(10 * 60 * 1000);
}
I want to be able to run this code and have it work without being prompted for uac.
This is why i do not like stack overflow, you ask a specific question and rarely get a specific answer. Then get marked down for asking a valid question. I figured it out about 2 minutes after i posted. Thanks to those to actually tried to help for being constructive and helping.
If you want to start a new process and if you want process to run as administrator, you need RunAs verb.
UAC prompt will be shown ONLY IF the process invoker does not have administrative rights.
For your case, if you do not want process to be executed as Admin, then you should remove below line from the code:
process.StartInfo.Verb = "runas";

Start Azure Storage Emulator for non-Admin users on Startup

At work we use Azure functions for simple tasks.
To debug or run the function you need a running Azure Storage Emulator.
The problem is that our developer accounts don't have admin privileges so we can't start the emulator ourselves.
For now we solve this by asking an admin to start it for us, but that works only until you restart/turn off the machine.
We tried many things for the emulator to start for each user( as if it was run by the admin) but nothing worked.
Here is one of the methods we tried. A simple program that runs at startup and starts the emulator. If you start it manually as admin it does the job and the emulator starts without problems.
But when scheduled to start(with the admin account) at startup or at logon it starts it but only for the admin account and not the current user.
Code for the program we run at startup:
internal class Program
{
private static void Main(string[] args)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = #"C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe";
startInfo.Arguments = "start";
process.StartInfo = startInfo;
process.Start();
}
}
Do you have any idea or suggestions how to solve the above problem ?
P.S:I have searched the related topics posted on StackOverflow for issues of the same kind but they ware not much help or the use-case was different.
:)
As per this link: the first time you run your emulator, the emulator environment will need to configure itself: it will create a database in LocalDB and it will register some HTTP ports. In order for the configuration process to succeed, you need administrator privilege.
The next time you'll run the storage emulator, you will no longer need administrator privilege.
So there is a tricky way, just for your reference.
you can use administrator to start the emulator, then wait for a few seconds(it finishes the inialization), stop emulator.
Then you can use normal user account to start it, it would be run for you.
Code like below:
with admin account:
private static void Main(string[] args)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = #"C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe";
startInfo.Arguments = "start";
process.StartInfo = startInfo;
process.Start();
//Wait for finished initialization
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));
//After initialization, close the Emulator
Process[] processes = Process.GetProcessesByName("AzureStorageEmulator");
foreach (var p in processes)
{
p.Kill();
}
}
Then you can start Emulator again using your developer account, the code is similar to the above.
It maybe a not good choice, you can also submit an question on here.

What is reliable way to start external program for c# application

From my C# application I want to start another application that requires admin privilleges and has manifest that ensures it.
My part of code:
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(#"MyLauncher.exe");
startInfo.Arguments = "/a";
startInfo.UseShellExecute = true;
startInfo.Verb = "runas";
System.Diagnostics.Process p = System.Diagnostics.Process.Start(startInfo);
Thread.Sleep(5000);
Current.Shutdown();
Unfortunatelly sometimes application start smoothly but from time to time only UAC dialog appears but the application does not start.
I tried different startup settings but no luck.

Run process under current user

There is "Setup project" in VS. During installation I launch another process:
System.Diagnostics.Process process = new System.Diagnostics.Process();
//fill StartInfo and run call Start()
process.Start();
If I run installer under Windows 7 and install for "Everyone", process start under the SYSTEM. If I install "Just for me", process start under Current user. How do I always start process under Current user?
I have found very simple solution. All that you need it just create a new class and copy text from this link.
To launch the process call ProcessAsUser.Launch("program name");
I had a similar problem: My setup extension (custom action) needed Admin privileges which brought up an elevation box. After I start my application at the end of "Just for Me" the process had settings that were made for the admin context. For example my user account likes to see all extensions of files in Windows Explorer but the admin account was configured to hide them. So in every file open box I couldn't see the extensions. To cure this this piece of code worked:
ProcessStartInfo startInfo = new ProcessStartInfo(ShortcutTarget);
startInfo.LoadUserProfile = true;
startInfo.UseShellExecute = false;
Process.Start(startInfo);
It works only in "Just for Me" mode, in "Everyone" the admin's settings are used. But this is ok for me.
Use ProcessStartInfo class and its property UserName, then use it as argument for Process.Start static method.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Process.Start(startInfo);

How do you call an exe from code and get around possible UAC action against this?

I'm using system.diagnostics.process to start an msi file in quiet mode. I'm getting an exit code 1625, and I suspect its because UAC is preventing it from running. I've turned off the UAC prompts but no dice...
How can I make sure that I'm properly elevating the privileges of the msiexec so it actually runs?
Thanks,
Isaac
UAC Elevation in Managed Code: Starting Elevated Processes
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "/i " + "\""+Directory.GetCurrentDirectory()+"\\"+msiPath +"\"" +" /q";
startInfo.FileName = "msiexec.exe";
startInfo.Verb = "runas";
Process installProcess = Process.Start(startInfo);
Well, this is what I did, and it works.
Try running your process with the admin privileges and see if the problem persists

Categories

Resources