Setting custom shell with admin privileges - powershell

I am able to set an application to launch on boot-up using custom shell in Windows 10(Powershell script) to achieve Kiosk mode.
I want it to run as 'Admin', for that I disabled UAC and made it elevated in application manifest file. When I start the system a black screen pops up and the application is not visible in task manager as well(it seems application not started).
If I set it not to run as 'Admin' then it is working fine but it will not be running as elevated.
Does anybody have any idea how to launch application in admin mode using custom shell?
Thanks,
Soma

I've had the same problem with ShellLauncher on Windows 10. The solution however is the same. Turn off User Account Control (UAC). Then, create a VBScript file with the following content, named as, say, 'launcher.vbs':
set shell = CreateObject("wscript.shell")
cmd = "{Path to your Exe}\App.exe"
shell.run cmd,,true
And set the shell as "wscript.exe {path to your launcher}.vbs"

Related

launch edge in kiosk mode from batch or powershell

I'll take a batch or powershell solution, but I need to launch Edge to a specific url in kiosk mode and not having much luck. The following sees the kiosk parameter as part of the url string. This method of launching the app doesn't appear to accept parameters
start "" "shell:AppsFolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge" --Kiosk http://website.com
In powershell but it keeps telling me the application was not found, enter a valid appname or AUMID. But that is the correct aumid and its recognized by the batch file.
set-assignedAccess -UserName "kiosk" -AppName "Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge --kiosk http://website.com"
Though similar this is not a duplicate of How to set up Microsoft Edge Chromium in kiosk mode with silent printing?
They reference edge from program files and mine is not located there. Above has been the only way I've been able to reference it successfully from batch.

How to ask for administrative privilege only once in OSX?

So I have an app that runs shell command twice, once to disable sleep and then a few moments later to enable sleep. The code looks as follows:
NSAppleScript(source: "do shell script \"sudo pmset -a disablesleep 1\" with administrator " +
"privileges")!.executeAndReturnError(nil)
// and then same code with with '0' instead of 1 to disable it
However the issue is I don't want the user to enter their password EVERYTIME they call these commands. It's making for a poor user experience. Is there a way I can grant the entire app admin privilege and run shell commands however I want? Or is there a way to run this shell command without the user authorization?

Running a gui app with Powershell without displaying the gui

I want to run an app (it does not natively support command line mode) on Windows that require 5 fields of generic data from a user. However, I want to run this app without opening/displaying the gui (a la command line like). Is this something that can be done with Powershell. If so, can someone point me in the right direction. Thanks in advance
PowerShell does not change how an application is executed versus how it is when executed at the command line or a run dialog. If the application can accept input via arguments when run then any of these methods for executing the application will work.
If you are asking if powershell can read from the console host, the appropriate cmdlet would be read-host. So you could read from the user and then run the command with the arguments you desire.
$user = read-host "Username:"
& examplecommand.exe $user

Psexec executed cmd to run further programs which require user input

I have a small problem with my Powershell script.
What do i want:
open CMD via PSEXEC on a remote machine, and work in this "remoteshell" as if i am in front of this machine. There is a commandline tool which i'd like to run, which requires user input after its started (it runs a own "shell")
What the problem is:
i utilize PSEXEC 2.11 with the following command
.\PSEXEC \\$Global:Endpoint -s -accepteula cmd
Cmd gets started as expected.
When i enter the name of the tool (lets call it tool.exe) the inital screen is loaded. But when the shell appears, nothing happens. I can enter commands but there will be no feedback...
C:\windows\System32>tool.exe
Testing Tool V1.0
Command? >
Then nothing can be entered anymore...
I even cannot stop it by pressing CTRL+C. I need to close the application window to force it to close. :(
Any ideas? Are there programs which cannot run in "user interaction" mode?
For reasons, it cannot run as a window visible on the remote endpoint. It needs to run silent.

Why is the Powershell Environment PATH different to the System Environment PATH?

I'm having this weird situation :
My user's and system's PATH variable is different than the PATH in powershell.
When I do :
PS C:\$env:path
C:\Windows\System32\WindowsPowerShell\v1.0\;c:\oldpath
However this is not correct, it looks like it stuck on some old PATH variable of my system, so none of the udpates I've done on it didn't change this variable (I do restart after every change to test).
Why is this happening? Do I have to set a PATH variable just for powershell?
The change might be "delayed", so try one or more of these solutions:
Log off and on again;
Task Manager > Restart "Windows Explorer" (explorer.exe)
Restart your launcher app (launchy, SlickRun, etc)
Reboot
Explanation:
Powershell will inherit the environment of the process that launched it (which depends on how you launch it). This is usually the interactive shell (explorer.exe). When you modify the environment from computer properties, you modify the environment of explorer.exe, so if you launch powershell from explorer.exe, (for example from the start menu) you should see the new environment.
However, if you launch it from something else (say a cmd.exe shell that you already had opened), then you won't since that process was launched under the old environment.
In other words: be careful how you are launching things.
In my case, I installed an app that incorrectly added itself to the PATH by creating a powershell profile that would override $env:PATH and blow out the existing configuration every time I started powershell.
Check if you have profile at USER\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 and if it's doing anything fishy like setting $env:PATH.