hello, sorry for my bad English this code does not work Code: IF NOT EXIST "D:\SOURCE\A" ( SET A=D:\SOURCE SET B=%A%\tata ) ECHO. %B% result is \tata why %a% is not initialized? thanks
You need to use delayed expansion. Code: @ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION IF NOT EXIST "D:\SOURCE\A\" ( SET "A=D:\SOURCE" SET "B=!A!\tata" ) ECHO. %B% PAUSE You could of course just arrange things a little differently. Code: @ECHO OFF SETLOCAL ENABLEEXTENSIONS SET "A=D:\SOURCE" IF NOT EXIST "%A%\A\" (SET B=%A%\tata) ECHO. %B% PAUSE
Sorry if off topic. I want to run two exe files on first logon after Windows 7 installation completion. First file name: one.exe Second file name: act.exe Any one can guide me how to do this? If this require setupcomplete.cmd, please compile cmd for this. Thanks
You can do something like this... (assumes that exe's and cmd file are in the scripts folder for this example) Step one to add reg entry in setupcomplete.cmd: Code: reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v !RUN /t REG_SZ /d "%windir%\Setup\scripts\Run.cmd" /f >nul Step two to create the Run.cmd itself to install the two exe's: Code: @echo off IF EXIST "%windir%\Setup\scripts\one.exe" CALL "%windir%\Setup\scripts\one.exe" IF EXIST "%windir%\Setup\scripts\one.exe" DEL /F /Q "%windir%\Setup\scripts\one.exe" >nul IF EXIST "%windir%\Setup\scripts\two.exe" CALL "%windir%\Setup\scripts\two.exe" IF EXIST "%windir%\Setup\scripts\two.exe" DEL /F /Q "%windir%\Setup\scripts\two.exe" >nul DEL /F /Q "%~f0"&EXIT >nul