When creating a Post-Build event in VS2008, I want to check if the target for an xcopy operation is not readonly. I found some code ( http://forums.techguy.org/dos-other/842311-solved-checking-if-file-folder.html ) that makes use of a temporary variable and later checks that for certain attribs. It does not work. When I manually print the variable, it seems to be empty.
if $(PlatformName)==x86 (
echo x86
For /F "Delims=" %%I In ('Attrib $(ProjectDir)..\..\somedir\$(ConfigurationName) \somemoredir\$(TargetName).dll') Do Set _Attribs=%%I
If NOT "%_Attribs:~5,1%"=="R" (
set test="monkey"
echo %test%
echo $(test)
echo nono
echo %_Attribs%
echo $(ProjectDir)..\..\somedir\$(ConfigurationName)\somemoredir\$(TargetName).dll
attrib $(ProjectDir)..\..\somedir\$(ConfigurationName)\somemoredir\$(TargetName).dll
xcopy /Y $(ProjectDir)..\..\..\Runtime\bin\$(TargetName).* $(ProjectDir)..\..\somedir\$(ConfigurationName)\somemoredir\
)
)
output is:
x86 ECHO is on. ECHO is on. nono ECHO is on.
then the attrib message and so on.
echo %test%, echo $(test) and so on seem to show that the test variable does not contain anything.
How can I use environment variables?
(BTW, _Attribs, which I am really interested in, also does not contain anything.)