@@ -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
0 commit comments