start-process

Launch Metro style apps using powershell

感情迁移 提交于 2019-11-29 19:51:45
问题 I am trying to write a powershell script for windows 10 that will automatically launch a Metro-style app. The Start-Process cmdlet seems like it should work, but I cannot get it to launch anything unless I provide a path to the .exe For example, the following input works: Start-Process 'C:\Program Files\Internet Explorer\iexplore.exe' Unfortunately, Metro-style apps do not have an executable file. What file do I need to use to launch them? If I wanted to launch Windows Store for example, how

PowerShell - script 1 calls script 2 - how to return value from script 2 to script 1

好久不见. 提交于 2019-11-29 16:31:16
I have two PowerShell scripts. One script invokes another PowerShell script using elevated credentials, using Start-Process . But I am struggling with how to make the second script return the output value to the first script. Here is script # 1, which is invoked with script1.psl "sender-ip=10.10.10.10" function getUser($abc) { <#Previously created password file in C:\Script\cred.txt, read-host -assecurestring | convertfrom-securestring | out-file C:\Script\cred.txt#> $password = get-content C:\Script\cred.txt| convertto-securestring $credentials = new-object -typename System.Management

Powershell Opening File Path with Spaces

自闭症网瘾萝莉.ら 提交于 2019-11-29 14:05:47
问题 Im my PS script I want to be able to run another script in another PS instance by doing the following: $filepath = Resolve-Path "destruct.ps1" start-process powershell.exe "$filepath" destruct.ps1 is in the same folder as this script However when running this script in a location which includes spaces ("C:\My Scripts\") i will get the following error: The term 'C:\My' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. I know by using a '&

How to start remotely process in PowerShell

前提是你 提交于 2019-11-29 10:21:21
I have a problem, I have a script which: Connect with PSSession (I use PSSession with admin account) Stop 2 process Do change on them files Start the 2 process (Problem here) I want to start process on server, so i'm connect with PSSession (No problem) I do Invoke-Command : # $pathProg path to my program Invoke-Command -session $mySession -command {Start-Process $($args[0])} -ArgumentList $pathProg But it does nothing (I verify with VNC) I do Invoke-Command too : # $pathProg path to my program Invoke-Command -session $mySession -command {&$($args[0])} -ArgumentList $pathProg It lauch the

running dos command line from C#?

你。 提交于 2019-11-29 03:54:12
I am trying to run this command from command-line prompt: "D:\\fiji\\fiji.exe -macro D:\\fiji\\macros\\FFTBatch.ijm --headless" It works perfect when I type it in a command-line console. However, when I was trying to make it work from C# application, it failed. I tried following, but seems the command above did not get executed somehow: string fijiCmdText = "D:\\fiji\\fiji.exe -macro D:\\fiji\\macros\\FFTBatch.ijm --headless"; System.Diagnostics.Process.Start("cmd.exe", fijiCmdText); Anyone has any idea how to change it to work? Thanks. Nick X Tsui The problem was solved as in the direction

Start non-elevated process from elevated process [duplicate]

房东的猫 提交于 2019-11-28 12:16:07
Possible Duplicate: How to run NOT elevated in Vista (.NET) How do you de-elevate privileges for a child process My program running as an elevated process, and starting new processes with Process.Start() . For security reasons, I would like to run those new processes as non-elevated. How to do that? Michael Goldshteyn Take a look at: How to run NOT elevated in Vista (.NET) The answer is presented at that URL. Also, you may want to read http://go.microsoft.com/fwlink/?LinkId=81232 for why this is not such a good idea... 来源: https://stackoverflow.com/questions/3927790/start-non-elevated-process

Powershell Start-Process : This command cannot be executed due to the error: Access is denied

天涯浪子 提交于 2019-11-28 05:47:28
问题 I'm trying to run start-process from a powershell script with given credential. Nevertheless the command fail with the following error: Start-Process : This command cannot be executed due to the error: Access is denied Here is the full error log: 18-Jun-2015 11:48:54 Start-Process : This command cannot be executed due to the error: Access is den 18-Jun-2015 11:48:54 ied. 18-Jun-2015 11:48:54 At C:\Windows\system32\config\systemprofile\AppData\Local\Temp\PRISMA-AMR-JOB1- 18-Jun-2015 11:48:54

How to start remotely process in PowerShell

☆樱花仙子☆ 提交于 2019-11-28 03:42:54
问题 I have a problem, I have a script which: Connect with PSSession (I use PSSession with admin account) Stop 2 process Do change on them files Start the 2 process (Problem here) I want to start process on server, so i'm connect with PSSession (No problem) I do Invoke-Command : # $pathProg path to my program Invoke-Command -session $mySession -command {Start-Process $($args[0])} -ArgumentList $pathProg But it does nothing (I verify with VNC) I do Invoke-Command too : # $pathProg path to my

Start-process raises an error when providing Credentials - possible bug

非 Y 不嫁゛ 提交于 2019-11-28 00:47:41
Would you possibly know why this error is being raised in response to the code below. User-name and password have been verified as correct. $secPassword = ConvertTo-SecureString "Password" -AsPlaintext -Force $farmCredential = New-Object System.Management.Automation.PsCredential "SharePoint\SP_Farm",$secPassword Start-Process $PSHOME\powershell.exe -Credential $FarmCredential -ArgumentList "-NoExit","-Command `"&{`$outvar1 = 4+4; `"write-output `"Hello:`"`$outvar1`"}`"" -Wait the error; Start-Process : This command cannot be executed due to the error: The directory name is invalid. At C:\Users

Powershell Start Process, Wait with Timeout, Kill and Get Exit Code

旧街凉风 提交于 2019-11-27 23:46:14
I want to repeatedly execute a program in a loop. Sometimes, the program crashes, so I want to kill it so the next iteration can correctly start. I determine this via timeout. I have the timeout working but cannot get the Exit Code of the program, which I also need to determine its result. Before, I did not wait with timeout, but just used -wait in Start-Process, but this made the script hang if the started program crashed. With this setup I could correctly get the exit code though. I am executing from ISE. for ($i=0; $i -le $max_iterations; $i++) { $proc = Start-Process -filePath