jfmartel Posted October 24, 2007 Share Posted October 24, 2007 Hello, I'd like to create a script that drops a file in the startup dir of each profile located on the computer.So far it's working pretty good, except for the profile that has space in its name. Exemple: Default UserHere is what I got so far:REM Drops all profile name in a temporary filedir "%_rootProfile%" /a:d /b > %SystemDrive%\_Profile.txtREM Read the file, line by line, then verifies if if "ALL USERS", in that case we do nothing. Then verifies if Profile name is valid (We don't want to drop in System Dir: Exemple: NetworkService). If the 2 condition are ok, drops the scripts in the startup dir.for /f %%f in (c:\_Profile.txt) do ( if not %%f=="All Users" ( if exist "%_rootProfile%\%%f\%_startupDir%" ( COPY "%_AppPath%\SetOfficeName.vbs" "%_rootProfile%\%%f\%_startupDir%")))Works great except when %%f = Default instead of "Default User"Any help is appreciated.Thanks Link to comment Share on other sites More sharing options...
Yzöwl Posted October 24, 2007 Share Posted October 24, 2007 The quickfix for your problem is likely changingfor /f %%f in (c:\_Profile.txt) do (tofor /f "delims=" %%f in (c:\_Profile.txt) do (Take a look at the attached batch file, and run it to see what it does, it may help!ProfDirs.cmd Link to comment Share on other sites More sharing options...
jfmartel Posted October 24, 2007 Author Share Posted October 24, 2007 Wow! How complicated is that batch file! Works great! I'll adjust it to use it in my script.Thanks! Link to comment Share on other sites More sharing options...
Yzöwl Posted October 24, 2007 Share Posted October 24, 2007 Its not very complicated at all, its only 5 lines and took about 3 minutes to create. Since your question was about 'FOR loops', I just decided to use two of them! Link to comment Share on other sites More sharing options...
jfmartel Posted October 24, 2007 Author Share Posted October 24, 2007 Now having another problem, i want to use the var defined in the fisrt loop to define a new var for the root of all profile<snip>COPY "%_AppPath%\SetOfficeName.vbs" "%PD_%\%%?\%_startupDir%" /Y</snip>In the COPY, still uses the %SYSTEMDRIVE% and it seems that the command COPY doesn't like it... Link to comment Share on other sites More sharing options...
Yzöwl Posted October 24, 2007 Share Posted October 24, 2007 The variable shouldn't really be affecting the copy command, but to make it a little less complicated:The first for loop only gives you the location %PD_%. What you should do from there is move to that location. The second loop then could then have the "%PD_%" removed and the copy would then just stateCOPY "%_AppPath%\SetOfficeName.vbs" "%%?\%_startupDir%"The location then being relative to the current one.Attached is an example with 'less complicated' code!ProfDir2.cmd Link to comment Share on other sites More sharing options...
jfmartel Posted October 25, 2007 Author Share Posted October 25, 2007 Alright, again, thank you very much. 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