using a wild card in a script in a directory name
I'm writing a script in which i want to copy a file from my directory to the "Start Menu\Programs\Startup" in the computer. My problem is - this script is for several computers and from some reason in each one the administrator has a different name,so the path "C:\Documents and Settings*administrator*\Start Menu\Programs\Startup" is not suitable for all.
I'm looking for a way to use a wild card in the directory name . something like: "C:\Documents and Settings\administrator*\Start Menu\Programs\Startup", so my script will work in all computers. (the name is unknown from advanc开发者_运维技巧e but i do know that it will start with the word 'administrator')
Any ideas? Thanks,
Tamar
There are probably more clever ways, but one way would be to use the for
command. Something like the following:
cd "c:\documents and settings"
for /D %%f in (administrator*) do copy yourfile "%%f\start menu\programs\startup"
May be the variable
%userprofile%
could be useful for you. It gives you directly the path "C:\Documents and Settings\CurrentLoggedUser".
精彩评论