Skip to content

Commit 245cd6e

Browse files
committed
Some more fun with conhost and double quotes.
1 parent ce9792a commit 245cd6e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

script-corecycler.ps1

+15-2
Original file line numberDiff line numberDiff line change
@@ -2525,11 +2525,24 @@ function Start-YCruncher {
25252525
# This doesn't steal the focus
25262526
# We need to use conhost, otherwise the output would be inside the current console window
25272527
# Caution, calling conhost here will also return the process id of the conhost.exe file, not the one for the Y-Cruncher binary!
2528-
# Triple double quotes?
2529-
$processId = [Microsoft.VisualBasic.Interaction]::Shell(('conhost """' + $stressTestPrograms['ycruncher']['fullPathToExe'] + '""" config """' + $stressTestConfigFilePath + '"""'), 'MinimizedNoFocus')
2528+
2529+
2530+
# TODO: There seem to be some problems with starting the process here. Need to investigate
25302531
#$processId = [Microsoft.VisualBasic.Interaction]::Shell(('conhost "' + $stressTestPrograms['ycruncher']['fullPathToExe'] + '" config \"' + $stressTestConfigFilePath + '\"'), 'MinimizedNoFocus')
25312532
#$processId = [Microsoft.VisualBasic.Interaction]::Shell(('conhost "' + $stressTestPrograms['ycruncher']['fullPathToExe'] + '" config \"' + $stressTestConfigFilePath + '\"'), 'NormalNoFocus')
25322533
#$processId = [Microsoft.VisualBasic.Interaction]::Shell(('conhost "' + $stressTestPrograms['ycruncher']['fullPathToExe'] + '" config \"' + $stressTestConfigFilePath + '\"'), 'Hide')
2534+
2535+
2536+
# The escape character in Visual Basic for double quotes seems to be... a double quote!
2537+
# So a triple double quote is actually interpreted as a single double quote here
2538+
$processId = [Microsoft.VisualBasic.Interaction]::Shell(('conhost """' + $stressTestPrograms['ycruncher']['fullPathToExe'] + '""" config """' + $stressTestConfigFilePath + '"""'), 'MinimizedNoFocus')
2539+
2540+
2541+
# Possible alternative using cmd /K with even more quotes
2542+
# Note that this will not work with the GetWindows() call to match against "^.*00-x86\.exe$", as the window title doesn't end with .exe, but with
2543+
# "[...]00-x86.exe" config "[...]\stressTest.cfg"
2544+
#$processId = [Microsoft.VisualBasic.Interaction]::Shell(('conhost.exe cmd /K """"""' + $fullPathToExe + '""" config """' + $stressTestConfigFilePath + '""""""'), 'MinimizedNoFocus')
2545+
25332546

25342547
# Cannot use the returned $processId here
25352548
#$Script:windowProcess = Get-Process -Id $processId

0 commit comments

Comments
 (0)