May 12, 201016 yr Hi,I created an sfx installer with Windows Live Essential Addon Maker 3.5.. It works good but after install I want to copy two files that If a user has installed winamp or aimp it should copy to plugins folder.. I use if not exist because my winamp also install with this file. so I just want it if not exist.here is my batch file;@Echo Offcwnd /HIDE @start /wait wlm2009_416.exexcopy "Windows Live Messenger.lnk" "%ALLUSERSPROFILE%\Desktop" /Y /EIF NOT EXIST "%programfiles%\Winamp\Plugins\gen_MSN.dll" ( xcopy "gen_MSN.dll" "%programfiles%\Winamp\Plugins\gen_MSN.dll") ELSE ( goto exits:exitsEXITcould anyone help please. it doesn't copy :S I don't understand why. Edited May 13, 201016 yr by ZEUS__
May 12, 201016 yr Maybe try this @Echo Offcwnd /HIDE @start /wait wlm2009_416.exexcopy "Windows Live Messenger.lnk" "%ALLUSERSPROFILE%\Desktop" /Y /ESet File="%programfiles%\Winamp\Plugins\gen_MSN.dll"If Not Exist %File% Goto Work1If Exist %File% Goto TheEnd:Work1xcopy "gen_MSN.dll" %File%goto TheEnd:TheEndExit
May 13, 201016 yr Author sorry but it didn't work. it doesn't seem to work, just I see xcopy.exe on task manager.added:in fact I need to copy two files if they not in their path.. one is; if not exist "%programfiles%\AIMP2\Plugins\gen_msn7.dll"other is; if not exist "%programfiles%\Winamp\Plugins\gen_MSN.dll" Edited May 13, 201016 yr by ZEUS__
May 13, 201016 yr Author YAY, at the end. this is my art I tried something and I don't know how it works but it works like a charm here's:@Echo Offcwnd /HIDE @start /wait wlm2009_416.exexcopy "Windows Live Messenger.lnk" "%ALLUSERSPROFILE%\Desktop" /Y /EIF NOT EXIST "%programfiles%\Winamp\Plugins\gen_MSN.dll" (xcopy "gen_MSN.dll" "%programfiles%\Winamp\Plugins" /Y) ELSE (goto Aimp):AimpIF NOT EXIST "%programfiles%\AIMP2\Plugins" (goto 1:1md "%programfiles%\AIMP2\Plugins") ELSE (goto 2)IF NOT EXIST "%programfiles%\AIMP2\Plugins\gen_msn7.dll" (goto 2:2xcopy "gen_msn7.dll" "%programfiles%\AIMP2\Plugins" /Y) ELSE (goto exit):exitEXIT
May 13, 201016 yr Nice. Here's the same code, without the unnecessary GOTOs.@Echo Offcwnd /HIDE @start /wait wlm2009_416.exexcopy "Windows Live Messenger.lnk" "%ALLUSERSPROFILE%\Desktop" /Y /EIF NOT EXIST "%programfiles%\Winamp\Plugins\gen_MSN.dll" ( xcopy "gen_MSN.dll" "%programfiles%\Winamp\Plugins" /Y)IF NOT EXIST "%programfiles%\AIMP2\Plugins" ( md "%programfiles%\AIMP2\Plugins")IF NOT EXIST "%programfiles%\AIMP2\Plugins\gen_msn7.dll" ( xcopy "gen_msn7.dll" "%programfiles%\AIMP2\Plugins" /Y)EXIT
May 13, 201016 yr Or perhaps this would make more sense…@CWND /HIDE @START /WAIT wlm2009_416.exeCOPY "Windows Live Messenger.lnk" "%AllUsersProfile%\Desktop"IF NOT EXIST "%ProgramFiles%\Winamp\Plugins\gen_MSN.dll" ( COPY "gen_MSN.dll" "%ProgramFiles%\Winamp\Plugins")IF NOT EXIST "%ProgramFiles%\AIMP2\Plugins\gen_msn7.dll" ( IF NOT EXIST "%ProgramFiles%\AIMP2\Plugins" ( MD "%ProgramFiles%\AIMP2\Plugins") COPY "gen_msn7.dll" "%ProgramFiles%\AIMP2\Plugins")The @Echo off wasn't required because the window was being hidden!XCOPY isn't required since none of its special switches are required!There's no need to check for the existence of the AIMP\Plugins directory unless the file doesn't exist, (that location would exist if the file was found in it)!There's likely no need for the EXIT command, the script should end on its own!
May 13, 201016 yr As a side note, and only as a "philosophical" point, with no practical use whatever , the only "bad" thing that can happen if you try mkdir giving an existing directory is that an error message will be output to STDERR, I have no idea (but it may be worth a test ) if by unconditionally making the dir anyway would it be faster than looping to the "directory" IF NOT EXIST, when a great number of file needs to be copied.I.E. something like:FOR %%? IN ("%ProgramFiles%\Winamp\Plugins\gen_MSN.dll""%ProgramFiles%\AIMP2\Plugins\gen_msn7.dll") DO CALL :Copyfiles %%?GOTO :EOF:CopyfilesMD "%~dp1" >NUL 2>&1IF NOT EXIST "%~dpnx1" COPY "%~nx1" "%~dpnx1"GOTO :EOFjaclaz
May 13, 201016 yr Also, you'll note that you've made no provision for the fact that it would be good practice to verify whether Winamp or AIMP are installed first. (or at the very least check that the AIMP and Winamp directories exist in %ProgramFiles%.) If they aren't there then it would be pointless creating folder structures and placing files there!
April 10, 201313 yr I need something similar. IF NOT EXIST FILE1 OR FILE2 THEN DEL FILE3 A couple of ideasIF EXIST FILE.ONE (IF EXIST FILE.TWO (GOTO :NEXT))DEL FILE.THREE:NEXTIF NOT EXIST FILE.ONE SET _OR=TIF NOT EXIST FILE.TWO SET _OR=TIF DEFINED _OR DEL FILE.THREE
April 10, 201313 yr I need something similar. IF NOT EXIST FILE1 OR FILE2 THEN DEL FILE3 A couple of ideasIF EXIST FILE.ONE (IF EXIST FILE.TWO (GOTO :NEXT))DEL FILE.THREE:NEXTIF NOT EXIST FILE.ONE SET _OR=TIF NOT EXIST FILE.TWO SET _OR=TIF DEFINED _OR DEL FILE.THREEThanks, but I'm trying to delete FILE.THREE only if FILE.ONE or FILE.TWO don't exist. Edited April 10, 201313 yr by PROBLEMCHYLD
April 10, 201313 yr The VBS way of doing what you want.Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") If Not Fso.FileExists("Text1.txt") And _ Not Fso.FileExists("Text2.txt") Then MsgBox "Delete Text3.txt" Else MsgBox "Text1 or Text2 Exists" End If
April 10, 201313 yr The VBS way of doing what you want.Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") If Not Fso.FileExists("Text1.txt") And _ Not Fso.FileExists("Text2.txt") Then MsgBox "Delete Text3.txt" Else MsgBox "Text1 or Text2 Exists" End If Thanks, but I need it in BATCH format, because WSH is not present at the time. Also your script looks good but it didn't delete the file. I will have a use for it in the future.
Create an account or sign in to comment