ZEUS__ Posted May 12, 2010 Share Posted May 12, 2010 (edited) 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, 2010 by ZEUS__ Link to comment Share on other sites More sharing options...
gunsmokingman Posted May 12, 2010 Share Posted May 12, 2010 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 Link to comment Share on other sites More sharing options...
ZEUS__ Posted May 13, 2010 Author Share Posted May 13, 2010 (edited) 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, 2010 by ZEUS__ Link to comment Share on other sites More sharing options...
ZEUS__ Posted May 13, 2010 Author Share Posted May 13, 2010 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 Link to comment Share on other sites More sharing options...
Guest Posted May 13, 2010 Share Posted May 13, 2010 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 Link to comment Share on other sites More sharing options...
ZEUS__ Posted May 13, 2010 Author Share Posted May 13, 2010 thanks @5eraph. it's much more clear:) Link to comment Share on other sites More sharing options...
Yzöwl Posted May 13, 2010 Share Posted May 13, 2010 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! Link to comment Share on other sites More sharing options...
ZEUS__ Posted May 13, 2010 Author Share Posted May 13, 2010 thank you so much @Yzöwl Link to comment Share on other sites More sharing options...
jaclaz Posted May 13, 2010 Share Posted May 13, 2010 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 Link to comment Share on other sites More sharing options...
Yzöwl Posted May 13, 2010 Share Posted May 13, 2010 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! Link to comment Share on other sites More sharing options...
PROBLEMCHYLD Posted April 10, 2013 Share Posted April 10, 2013 I need something similar. IF NOT EXIST FILE1 OR FILE2 THEN DEL FILE3 Link to comment Share on other sites More sharing options...
Yzöwl Posted April 10, 2013 Share Posted April 10, 2013 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 Link to comment Share on other sites More sharing options...
PROBLEMCHYLD Posted April 10, 2013 Share Posted April 10, 2013 (edited) 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, 2013 by PROBLEMCHYLD Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 10, 2013 Share Posted April 10, 2013 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 Link to comment Share on other sites More sharing options...
PROBLEMCHYLD Posted April 10, 2013 Share Posted April 10, 2013 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now