Skip to content

Commit c72c03f

Browse files
committed
Fix command prompt shell startup broken
1 parent 4e34705 commit c72c03f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/features/terminal/shells/cmd/cmdStartup.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ async function setupCmdStartup(cmdFiles: CmdFilePaths, key: string): Promise<boo
208208
const existingAutoRun = await getExistingAutoRun();
209209

210210
// Step 3: Create or update the main batch file
211+
const mainBatchContent = getMainBatchFileContent(cmdFiles.regStartupFile);
211212
if (await fs.pathExists(cmdFiles.mainBatchFile)) {
212213
const content = await fs.readFile(cmdFiles.mainBatchFile, 'utf8');
213214
if (hasStartupCode(content, regionStart, regionEnd, [cmdFiles.startupName])) {
214215
traceInfo(`SHELL: CMD main batch file at ${cmdFiles.mainBatchFile} already contains our startup file`);
215216
} else {
216-
const mainBatchContent = getMainBatchFileContent(cmdFiles.regStartupFile);
217217
await fs.writeFile(
218218
cmdFiles.mainBatchFile,
219219
insertStartupCode(content, regionStart, regionEnd, mainBatchContent),
@@ -222,6 +222,13 @@ async function setupCmdStartup(cmdFiles: CmdFilePaths, key: string): Promise<boo
222222
`SHELL: Updated existing main batch file at: ${cmdFiles.mainBatchFile}\r\n${mainBatchContent}`,
223223
);
224224
}
225+
} else {
226+
// Create new main batch file
227+
await fs.writeFile(
228+
cmdFiles.mainBatchFile,
229+
insertStartupCode(getHeader(), regionStart, regionEnd, mainBatchContent),
230+
);
231+
traceInfo(`SHELL: Created new main batch file at: ${cmdFiles.mainBatchFile}\r\n${mainBatchContent}`);
225232
}
226233

227234
// Step 4: Setup registry AutoRun to call our main batch file

src/features/terminal/terminalManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ export class TerminalManagerImpl implements TerminalManager {
177177

178178
if (
179179
(shellIntegrationEnabled || (await shellIntegrationForActiveTerminal(p.name))) &&
180-
!isWsl()
180+
!isWsl() &&
181+
p.shellType !== 'cmd'
181182
) {
182183
// Shell integration available and NOT in WSL - skip setup
183184
await p.teardownScripts();
@@ -196,7 +197,8 @@ export class TerminalManagerImpl implements TerminalManager {
196197
} else if (state === ShellSetupState.Setup) {
197198
if (
198199
(shellIntegrationEnabled || (await shellIntegrationForActiveTerminal(p.name))) &&
199-
!isWsl()
200+
!isWsl() &&
201+
p.shellType !== 'cmd'
200202
) {
201203
await p.teardownScripts();
202204
traceVerbose(

0 commit comments

Comments
 (0)