You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何隐藏runas命令执行时的‘Attempting to start’提示信息?

Fixing the "Attempting to start..." Prompt in runas with Long Parameters

Got it, let's tackle this annoying runas prompt issue. That verbose "Attempting to start (command)" message spitting out your thousand-character parameters is definitely a pain when you're trying to keep your session clean. Here are a few reliable ways to suppress, hide, or redirect that output:

The best approach is to ditch direct runas calls and use PowerShell's Start-Process cmdlet, which gives you far more control over output and window behavior. It skips the runas-specific prompt entirely and lets you redirect all output to null.

Example:

# Get credentials securely (will prompt for username/password)
$credential = Get-Credential

# Launch the shortcut with the credentials, suppressing all output
Start-Process -FilePath "C:\Path\To\Your\Shortcut.lnk" `
    -Credential $credential `
    -RedirectStandardOutput $null `
    -RedirectStandardError $null `
    -NoNewWindow  # Optional: Remove if you want a new window for the app

This method completely avoids the "Attempting to start..." message because it doesn't use runas directly—you're launching the shortcut directly with elevated/alternate credentials via PowerShell.

2. Redirect runas Output to Null (If You Must Use runas)

If you need to stick with the runas command, you can redirect both standard output and standard error to null. The catch is that runas will still show the credential prompt, but the verbose start message will be suppressed.

Command Prompt (CMD) Syntax:

runas /user:DOMAIN\Username "C:\Path\To\Your\Shortcut.lnk" >nul 2>&1

The >nul redirects standard output to nothing, and 2>&1 sends standard error to the same place as standard output.

PowerShell Syntax:

& runas /user:DOMAIN\Username "C:\Path\To\Your\Shortcut.lnk" *> $null

The *> $null shorthand redirects all output streams (stdout, stderr, etc.) to null in PowerShell.

3. Hide the Entire runas Window

If you want to go a step further and hide the runas window entirely (along with the prompt), use Start-Process with the -WindowStyle Hidden parameter:

$credential = Get-Credential
Start-Process -FilePath "runas.exe" `
    -ArgumentList "/user:DOMAIN\Username `"C:\Path\To\Your\Shortcut.lnk`"" `
    -Credential $credential `
    -WindowStyle Hidden `
    -RedirectStandardOutput $null `
    -RedirectStandardError $null

This will run runas in a hidden window, so you won't see any prompts or messages at all—only the credential dialog will appear (which can't be suppressed for security reasons).


内容的提问来源于stack exchange,提问作者runCMD

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:34:54