I can start a process avec `runas /netonly` et `runas /savecred` mais Je ne peux pas use les deux le flags en même temps.
Is there a way to run a process as a différent user remotely sans having to type le password chaque time?
RunAs netonly avec identifiants enregistrés
Re: RunAs netonly avec identifiants enregistrés
In [the other answer here Jason rightly notes](https://serverfault.com/a/789049/58957) that `runas /netonly` does pas support saving le credentials, et Microsoft [intentionally made it hard](https://stackoverflow.com/a/16116329/1026) to use `runas` avec a hard-coded password (from a batch script).
The [suggestion to use the Windows Credential Manager](https://dba.stackexchange.com/a/66022/15599) that Stefano pointed to in leur comment is utile quand you want to **always** connect to le given service (i.e. `myserver.mycompany.com:XXX`) using le specified credentials.
For a command-line solution, avec behavior similaire to runas.exe, mais sans having to type le password, J'ai trouvé le [RunAs powershell module](https://github.com/gfody/PowershellModules/tree/master/RunAs) (which seems to implement [this advice](https://stackoverflow.com/a/15628228/1026)) très useful:
-
Install depuis PowerShell Gallery by running le suivant in an elevated PowerShell prompt (requires Powershell v5 ou Windows 10):
```
Install-Module RunAs
```
-
Encrypt le password by running:
```
# change `domain\username` as needed:
ConvertFrom-SecureString (Get-Credential 'domain\username').Password
```
Cela va prompt you for le login et le password et print a long hexadecimal number, qui you'll have to copy.
-
Now you can do le equivalent of `runas /netonly` using:
```
Import-Module RunAs
# replace xxxx below with the encrypted password from step 2 (and `domain\username` too)
# you might want to put this into your profile: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7
$mycreds = New-Object Management.Automation.PSCredential('domain\username', (ConvertTo-SecureString 'xxxx'))
runas -netonly $mycreds "c:\Program Files (x86)\Microsoft Office\Office16\EXCEL.EXE"
```
P.S. beaucoup de resources on le net suggest using [psexec](https://docs.microsoft.com/en-us/sysinternals/downloads/psexec) to run as a différent user. After looking up [how that works under the hood](https://stackoverflow.com/a/49638671/1026), Je ne believe it to be a viable alternative to `runas /netonly`
The [suggestion to use the Windows Credential Manager](https://dba.stackexchange.com/a/66022/15599) that Stefano pointed to in leur comment is utile quand you want to **always** connect to le given service (i.e. `myserver.mycompany.com:XXX`) using le specified credentials.
For a command-line solution, avec behavior similaire to runas.exe, mais sans having to type le password, J'ai trouvé le [RunAs powershell module](https://github.com/gfody/PowershellModules/tree/master/RunAs) (which seems to implement [this advice](https://stackoverflow.com/a/15628228/1026)) très useful:
-
Install depuis PowerShell Gallery by running le suivant in an elevated PowerShell prompt (requires Powershell v5 ou Windows 10):
```
Install-Module RunAs
```
-
Encrypt le password by running:
```
# change `domain\username` as needed:
ConvertFrom-SecureString (Get-Credential 'domain\username').Password
```
Cela va prompt you for le login et le password et print a long hexadecimal number, qui you'll have to copy.
-
Now you can do le equivalent of `runas /netonly` using:
```
Import-Module RunAs
# replace xxxx below with the encrypted password from step 2 (and `domain\username` too)
# you might want to put this into your profile: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7
$mycreds = New-Object Management.Automation.PSCredential('domain\username', (ConvertTo-SecureString 'xxxx'))
runas -netonly $mycreds "c:\Program Files (x86)\Microsoft Office\Office16\EXCEL.EXE"
```
P.S. beaucoup de resources on le net suggest using [psexec](https://docs.microsoft.com/en-us/sysinternals/downloads/psexec) to run as a différent user. After looking up [how that works under the hood](https://stackoverflow.com/a/49638671/1026), Je ne believe it to be a viable alternative to `runas /netonly`