run-as-admin | Golang example of using a manifest file | SSH Utils library
kandi X-RAY | run-as-admin Summary
kandi X-RAY | run-as-admin Summary
Golang example of using a manifest file to prompt "Run as administrator" on Windows
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- main is the main entry point
run-as-admin Key Features
run-as-admin Examples and Code Snippets
Community Discussions
Trending Discussions on run-as-admin
QUESTION
Is it possible to make a .NET application always an admin while being run on a user account without a UAC popup? I've spent some time searching for this capability but haven't found any satisfactory answers.
For some background info, users are running a test application in a manufacturing environment where a dongle is plugged into a USB(to serial) port. Sometimes windows messes up the COM port and cycling the port can resolve the issue. We have discovered we can do this programmatically with admin privileges, but we do not want the users to be admins, and we also don't want the users to deal with a UAC popup or, god forbid, click "no" on the UAC popup to disable our capabilities and mess up the entire process.
How do I force my .NET application to run as administrator? I have found this old thread but their solutions all require the user to be admin or the usual UAC popup.
Is there something we can do to enable this capability or are we forever chained to the UAC prompt? We do own these machines and control the applications and users running on them.
EDIT: We are cycling the COM port using this method:
...ANSWER
Answered 2022-Apr-07 at 16:22You can't, not without at least an UAC prompt. This is totally unavoidable, otherwise Windows wouldn't have any security if it was possible - it MUST be totally impossible, not just "difficult", to bypass UAC.
Some clues to solve anyway your problem:
- You can force your application to always ask for elevation (i.e. make it to require administrative privileges) since the first step. Dangerous, but at least, you won't mess the whole software chain: it would be elevated from start.
- You can ask for UAC only when it's really needed (for example, when launching a particular sub-process, or launching your own application in elevated mode while keeping context). Obviously, you'll ask again and again until the elevated subprocess is created: if user click on "No", then you try again to launch it. Annoying, but again, you won't mess up the whole process.
- You can write a Windows service, that will run under administrative privileges, to perform the COM cycle task you need. Then, you can invoke this service from non-elevated user space, without requiring any elevation. I would recommend this solution.
QUESTION
what I'm trying to do is setting up aliases to run Windows Terminal from file browser in the current directory, as admin or regular user. I'm not very familiar with powershell scripts and I'm trying to understand why my functions are called when the script is loaded instead of when the alias is called, which in turn runs terminals indefinitely..
Here is the script I wrote in $Profile
:
ANSWER
Answered 2022-Feb-07 at 14:50Quoting this excellent answer which explains really well what you're doing wrong:
PowerShell aliases do not allow for arguments.
They can only refer to a command name, which can be the name of a cmdlet or a function, or the name / path of a script or executable
The
Set-Alias
cmdlet creates or changes an alias for a cmdlet or a command, such as a function, script, file, or other executable. An alias is an alternate name that refers to a cmdlet or command.
This should help you understand what is going:
QUESTION
I want to use a batch script to start Docker in Windows Subsystem for Linux at login. It works when I run the batch file as administrator. So I followed this guide: Always Run Batch file as Administrator in Windows 10
Then I placed the shortcut into the Startup
folder. The script is started, but it exits always at the first line.
Then I tried to run manually the batch file in FreeCommander. The batch script works when I run the script as administrator via right click context menu item. But there is output an error message when I run the batch script with a double click. The output error message is:
The command "wsl" is either misspelled or could not be found.
This is the batch script:
...ANSWER
Answered 2021-Nov-29 at 17:21There should be read first the following Microsoft documentation pages:
There are two system directories on 64-bit Windows with a processor with AMD64 architecture:
%SystemRoot%\System32
with 64-bit applications used by 64-bit applications by default.%SystemRoot%\SysWOW64
with 32-bit applications used by 32-bit applications by default.
The system environment variable PATH
contains by Windows default %SystemRoot%\System32
as first folder path. If a 32-bit application starts cmd.exe
to process a batch file, there is started 32-bit %SystemRoot%\SysWOW64\cmd.exe
because of the file system redirector.
cmd.exe
is searching for files specified in a batch file just with file name without or with file extension and without path by using the local environment variables PATHEXT
and PATH
as explained in full details by What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?
wsl.exe
belongs to the set of executables which on AMD64 Windows exists only as 64-bit version in %SystemRoot%\System32
. There is no 32-bit version in %SystemRoot%\SysWOW64
searched by 32-bit cmd.exe
on using %SystemRoot%\System32
in expanded form in local PATH
because of file system redirector. For that reason the batch file as posted in the question does not work on being processed by 32-bit cmd.exe
on Windows x64.
The solution is taking WOW64 into account with additional code in the batch file:
QUESTION
Is it possible to enable /disable touchscreen trough hid (Human Interface Devices in "Control Panel\All Control Panel Items\Device Manager") with standard user right (without elevated-privileges / admin access-rights) ?
I'm programing an application in C#. If I don't start my application trough "run as" on Visual Studio, security is blocking access.
What are my alternatives with my current setup / limitation:
- Standard user (basic right)
- Admin account with password in a secure encrypted file.
- The standard user cannot grant permission trough UAC because he don't have right.
- Using this code to check if user have elevated/admin right:
return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
Currently tested and not working:
Process with
startInfo.Verb = "runas";
Standard user can't accept UAC to run a process that require admin privilege / elevated. Elevating process privilege programmatically?App.manifest: Standard user can't accept UAC to run an app that require admin privilege / elevated. How do I force my .NET application to run as administrator?
Potential alternatives ?
- ACL ???
- App.manifest: with an install.msi from my "IT team packager with Zenwork or SCCM" to deploy it on computers user ?
- Service that run as "local service" or "system" and an app to call methods of service with an install.msi from my "IT team packager with Zenwork or SCCM" to deploy it on computers user ?
ANSWER
Answered 2021-May-06 at 17:31If you don't want to prompt the UAC in the moment of the administrative operation (using runas), or on every program start (via manifest), you need to create a Service or a Scheduled Task once, at first program setup. A lot of programs use this technique such as Chrome for updates, which normally don't require elevated privileges but for few occasional operations.
Choosing the service method means that you must implement an IPC mechanism for example via named pipe so the low privilege program can talk to the service and ask to execute the desired operation. Keep in mind that the service will always run in background and you shouldn't expose too much permissive operations otherwise other malicious programs could use your service to elevate themselves, or you'll need also an authentication method.
For the scheduled task you could use the same executable with a command line argument like /disabletouch. You only need to manually trigger the task from the low privilege instance. There are the TaskScheduler COM interface (some open-source wrappers exists around it) and the schtasks tool that allow task creation and manual triggers. The task can be created for running as Administrator or SYSTEM account. As for the service allow only strict and harmless elevated operations to prevent misuse.
QUESTION
I want Visual Studio 2019 on Windows 10 to always run as administrator from the task bar icon. I need to run several solutions as administrator, so admin should be the default.
Note: I want to run only 1 solution without admin privileges. For this 1 solution, using the recent solutions list from the taskbar icon works fine.
Related:
- VS2017 / VS 2019 Run As Admin from Recent solutions list. This is close, but I still want 1 solution to not run as admin.
- Make Visual Studio 2019 Always Run as Administrator from Start Bar Recent Solutions List This is essentially the same question as above. I flagged as a dup.
- Visual Studio Run as administrator shortcut This is close, but wants a desktop shortcut instead of a taskbar icon.
ANSWER
Answered 2021-Feb-25 at 19:32I want Visual Studio 2019 on Windows 10 to always run as administrator from the task bar icon.
Right-click the Visual Studio icon in your taskbar, or the shortcut on your desktop > right-click Visual Studio 2019 > Properties > Advanced... > Run as administrator > OK > Apply
Now when you open Visual Studio from the taskbar, you should see ADMIN in upper-right corner!
QUESTION
I'm running a PS 5.1 script that automatically elevates to run with admin privileges. The first part of the script runs a 3-minute check to make sure the environment is set up properly. The second part of the script asks for user input via read-host.
...ANSWER
Answered 2021-Jan-03 at 02:40I don't think the issue is connected to whether you're running elevated or not.
Assuming you're running in a console (terminal), you can clear the keyboard buffer as follows (adapted from this C# answer):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install run-as-admin
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page