Brent387
asked on
Problem with batch command
I am learning batch scripting and am playing around with it. For some reason, this code makes three folders on my desktop titled "and" "data" and "settings." This is the code:
echo off
rem This file will create the PacePatches folder. Each time a system is patched using logon scripts,
rem a .txt file will be placed in the folder confirming the successful patch deployment and
rem preventing repetitive installations
IF EXIST c:\%allusersprofile%\appli cation data\Paceinstalls\* (Goto Found) ELSE (Goto NotFound)
:NotFound
rem now creating folder
md %allusersprofile%\appdata\ PacePatche s
:Found
What do I need to change?
Thanks
echo off
rem This file will create the PacePatches folder. Each time a system is patched using logon scripts,
rem a .txt file will be placed in the folder confirming the successful patch deployment and
rem preventing repetitive installations
IF EXIST c:\%allusersprofile%\appli
:NotFound
rem now creating folder
md %allusersprofile%\appdata\
:Found
What do I need to change?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Type just
set
on it's own at the cmd.exe prompt to see all the variables and their values.
Steve
set
on it's own at the cmd.exe prompt to see all the variables and their values.
Steve
Yes, but no harm in quoting something that didn't need it, safer that way than assuming (eek, hate that word) that a path doesn't contain a space...
~bp
~bp
Bill, sorry I wasn't saying it didn't need quotes .. it certainly DOES like you say BUT he has added c:\ in front of %alluserprofiles% above which is what I meant was also breaking it ...
Of course it could be done more easily with just:
IF NOT EXIST "%allusersprofile%\applica tion data\Paceinstalls\*" md "%allusersprofile%\appdata \PacePatch es"
but there may be other reasons for doing it like it is.
IF NOT EXIST "%allusersprofile%\applica
but there may be other reasons for doing it like it is.
Gotcha Steve, sorry for the misunderstanding...
~bp
~bp
echo off
rem This file will create the PacePatches folder. Each time a system is patched using logon scripts,
rem a .txt file will be placed in the folder confirming the successful patch deployment and
rem preventing repetitive installations
IF EXIST "%allusersprofile%\applica
:NotFound
rem now creating folder
md "%allusersprofile%\appdata
:Found