@@ -10,8 +10,14 @@ import { ShellConstants } from '../../../common/shellConstants';
1010import { hasStartupCode , insertStartupCode , removeStartupCode } from '../common/editUtils' ;
1111import { ShellScriptEditState , ShellSetupState , ShellStartupScriptProvider } from '../startupProvider' ;
1212import { CMD_ENV_KEY , CMD_SCRIPT_VERSION } from './cmdConstants' ;
13+ import { StopWatch } from '../../../../common/stopWatch' ;
1314
14- const exec = promisify ( cp . exec ) ;
15+ function execCommand ( command : string ) {
16+ const timer = new StopWatch ( ) ;
17+ return promisify ( cp . exec ) ( command , { windowsHide : true } ) . finally ( ( ) =>
18+ traceInfo ( `Executed command: ${ command } in ${ timer . elapsedTime } ` ) ,
19+ ) ;
20+ }
1521
1622async function isCmdInstalled ( ) : Promise < boolean > {
1723 if ( ! isWindows ( ) ) {
@@ -94,9 +100,7 @@ async function checkRegistryAutoRun(mainBatchFile: string, regMainBatchFile: str
94100
95101 try {
96102 // Check if AutoRun is set in the registry to call our batch file
97- const { stdout } = await exec ( 'reg query "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun' , {
98- windowsHide : true ,
99- } ) ;
103+ const { stdout } = await execCommand ( 'reg query "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun' ) ;
100104
101105 // Check if the output contains our batch file path
102106 return stdout . includes ( regMainBatchFile ) || stdout . includes ( mainBatchFile ) ;
@@ -112,9 +116,7 @@ async function getExistingAutoRun(): Promise<string | undefined> {
112116 }
113117
114118 try {
115- const { stdout } = await exec ( 'reg query "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun' , {
116- windowsHide : true ,
117- } ) ;
119+ const { stdout } = await execCommand ( 'reg query "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun' ) ;
118120
119121 const match = stdout . match ( / A u t o R u n \s + R E G _ S Z \s + ( .* ) / ) ;
120122 if ( match && match [ 1 ] ) {
@@ -135,9 +137,8 @@ async function setupRegistryAutoRun(mainBatchFile: string): Promise<boolean> {
135137
136138 try {
137139 // Set the registry key to call our main batch file
138- await exec (
140+ await execCommand (
139141 `reg add "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /t REG_SZ /d "if exist \\"${ mainBatchFile } \\" call \\"${ mainBatchFile } \\"" /f` ,
140- { windowsHide : true } ,
141142 ) ;
142143
143144 traceInfo (
0 commit comments