Jump to content

Recommended Posts

Posted (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 Off
cwnd /HIDE @

start /wait wlm2009_416.exe
xcopy "Windows Live Messenger.lnk" "%ALLUSERSPROFILE%\Desktop" /Y /E
IF NOT EXIST "%programfiles%\Winamp\Plugins\gen_MSN.dll" (
xcopy "gen_MSN.dll" "%programfiles%\Winamp\Plugins\gen_MSN.dll"
) ELSE (
goto exits
:exits
EXIT

could anyone help please. it doesn't copy :S I don't understand why.

Edited by ZEUS__

Posted

Maybe try this


@Echo Off
cwnd /HIDE @

start /wait wlm2009_416.exe
xcopy "Windows Live Messenger.lnk" "%ALLUSERSPROFILE%\Desktop" /Y /E

Set File="%programfiles%\Winamp\Plugins\gen_MSN.dll"

If Not Exist %File% Goto Work1

If Exist %File% Goto TheEnd

:Work1
xcopy "gen_MSN.dll" %File%
goto TheEnd



:TheEnd

Exit

Posted (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 by ZEUS__
Posted

YAY, at the end. this is my art :P I tried something and I don't know how it works but it works like a charm :D

here's:

@Echo Off
cwnd /HIDE @

start /wait wlm2009_416.exe
xcopy "Windows Live Messenger.lnk" "%ALLUSERSPROFILE%\Desktop" /Y /E
IF NOT EXIST "%programfiles%\Winamp\Plugins\gen_MSN.dll" (
xcopy "gen_MSN.dll" "%programfiles%\Winamp\Plugins" /Y
) ELSE (
goto Aimp
)
:Aimp
IF NOT EXIST "%programfiles%\AIMP2\Plugins" (
goto 1
:1
md "%programfiles%\AIMP2\Plugins"
) ELSE (
goto 2
)
IF NOT EXIST "%programfiles%\AIMP2\Plugins\gen_msn7.dll" (
goto 2
:2
xcopy "gen_msn7.dll" "%programfiles%\AIMP2\Plugins" /Y
) ELSE (
goto exit
)
:exit
EXIT

Posted

Nice. :)

Here's the same code, without the unnecessary GOTOs.

@Echo Off
cwnd /HIDE @

start /wait wlm2009_416.exe
xcopy "Windows Live Messenger.lnk" "%ALLUSERSPROFILE%\Desktop" /Y /E

IF 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

Posted

Or perhaps this would make more sense…

@CWND /HIDE @

START /WAIT wlm2009_416.exe
COPY "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!

Posted

As a side note, and only as a "philosophical" point, with no practical use whatever :ph34r:, 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 :unsure:) 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

:Copyfiles
MD "%~dp1" >NUL 2>&1
IF NOT EXIST "%~dpnx1" COPY "%~nx1" "%~dpnx1"
GOTO :EOF

jaclaz

Posted

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!

  • 2 years later...
Posted

I need something similar.

IF NOT EXIST FILE1 OR FILE2 THEN DEL FILE3 ;)

A couple of ideas

IF EXIST FILE.ONE (IF EXIST FILE.TWO (GOTO :NEXT))
DEL FILE.THREE
:NEXT

IF NOT EXIST FILE.ONE SET _OR=T
IF NOT EXIST FILE.TWO SET _OR=T
IF DEFINED _OR DEL FILE.THREE

Posted (edited)

I need something similar.

IF NOT EXIST FILE1 OR FILE2 THEN DEL FILE3 ;)

A couple of ideas

IF EXIST FILE.ONE (IF EXIST FILE.TWO (GOTO :NEXT))
DEL FILE.THREE
:NEXT

IF NOT EXIST FILE.ONE SET _OR=T
IF NOT EXIST FILE.TWO SET _OR=T
IF DEFINED _OR DEL FILE.THREE

Thanks, but I'm trying to delete FILE.THREE only if FILE.ONE or FILE.TWO don't exist. Edited by PROBLEMCHYLD
Posted

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

Posted

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. :thumbup

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...