Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, January 10, 2018 8:12 PM
I have a machine which runs 4 console apps on the desktop. I am trying to figure out how I can spawn an admin cmd shell then run the application console app through it. The console app has to remain running and on the desktop. I am trying to get out of the habit of logging in and clicking till the cmd prompt is started then typing in the location etc to get it started. I want to write a script that will auto spawn four admin level cmd prompts then run one console app in each cmd shell.
All replies (6)
Wednesday, January 10, 2018 8:24 PM
Just create a shortcut to PowerShell on the desktop. You cannot bypass UAC but the shortcut can be set to automatically ask for elevation under "Advanced" button.
You issue is not a scripting issue but is one of how to use basic Windows features. "Shortcuts" are a basic feature of Windows.
\(ツ)_/
Wednesday, January 10, 2018 8:59 PM
I need to run a console app in a command shell. I am trying to create a script that will spawn 4 command prompts and then run one console app in each cmd shell. Starting powershell in admin is not the issue. Sorry maybe I didn't explain it right.
Wednesday, January 10, 2018 9:05 PM
help Start-Process -online
\(ツ)_/
Wednesday, January 10, 2018 9:50 PM
Well I am half way there. The following command will start the shell but how do I pipe in a program or command name?
start-process -filepath c:\windows\system32\cmd.exe /k
Wednesday, January 10, 2018 9:53 PM
Add a batch file as an argument.
Please read the whole help carefully. It has explicit instructions.
Mostly, it seems that you do not have much background in running Windows commands. You should first learn basic Windows and how commands are used and run.
Start-Process -FilePath notepad.exe -ArgumentList myfile.txt
CMD /C mybatch.bat
Start-Process mybatch.bat
Start-Process CMD -Argumentlist '/k mybatch.bat'
Start-Process CMD -Arg '/k dir c:\
\(ツ)_/
Friday, January 12, 2018 12:30 AM
I don't know if this helps answer your question, but as has already been mentioned, use a batch file to start your programs. I currently do this with several programs I need open when I log into specific servers and was tired starting each one separately.
If it is a PS1 file you can do something like whats below for your batch file.
This works on servers where I am too lazy to mess with the execution policy or creating a cert for the ps1 file.
@echo off
cd "C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe"
start powershell.exe -ExecutionPolicy Bypass -file "Z:\Patchinfo\script.ps1"
exit
Or if it's an executable file, you can have something like the following line in the batch file for each program. This line will run the "Run As" program and then use the creds I already have saved to run the program.
C:\Windows\System32\runas.exe /savecred /user:domain\user.name "cmd /c Start /B %windir%\system32\shutdown.exe -i"
Of course, you'll list the path and argument to your program you want to run.