Jump to content

sentinel1705

Member
  • Posts

    11
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

About sentinel1705

sentinel1705's Achievements

0

Reputation

  1. Yzöwl, that worked against a small test batch of users. I am going to make a full backup copy of our user profiles and run it against that to see what might fall out.
  2. The TSProfiles directory hosts just the user profile directories, of which they are all just user names. So no random 'default user' or 'administrator' folders. All pair up to an actual end-user. The entry I highlighted would be the only entry in the .ini file as well as the only entry that needs comparison against the parent folder for that user's profile. All of this would run locally on the server hosting the TSProfiles directory, which is a Windows Server 2003 box.
  3. I'm trying to figure out the best way to recursive search through one file (profile.ini) nested in each user's profile directory and compare an entry to the parent folder. If they match, move on, if they don't match, write that parent folder info to an updating text file. I got a lot of help here last time and was hoping for the same again, or at least get pointed in the right direction. See below for a crude example of what the process would be. Working Directory: D:\TSProfiles\ Full path: D:\TSProfiles\sentinel1705\windows\profile.ini Within Profile.ini, If CurrentWorkstation=Sentinel1705, Goto Next folder Else if Write Sentinel1705 to Badfile.txt Next
  4. Nevermind.... "dir E:\Notes\GPUpgrade\TSProfiles*.* " is not equal to "dir E:\Notes\GPUpgrade\TSProfiles\*.*
  5. I dumped all the profiles to my thumbdrive for testing and edited the paths accordingly, now I am getting the error message "The system cannot find the path specified." @echo off dir E:\Notes\GPUpgrade\TSProfiles*.* /b -o:d | find /v "." > E:\dirs.txt for /f "tokens=*" %%a in (E:\dirs.txt) do call :search "%%a" del E:\dirs.txt Echo The script has finished ping 127.0.0.0 -n 10 >nul goto EOF :search >>"E:\Notes\GPUpgrade\TSProfiles\%~1\windows\Profile.ini" Find /i "CHGPATH="<"E:\Notes\GPUpgrade\TSProfiles\%~1\windows\Profile.txt" >>"E:\Notes\GPUpgrade\TSProfiles\%~1\windows\Profile.ini" Find /i "CHGCurrentWS="<"E:\Notes\GPUpgrade\TSProfiles\%~1\windows\Profile.txt" >>"E:\Notes\GPUpgrade\TSProfiles\%~1\windows\Profile.ini" Find /i "POSCurrentWS="<"E:\Notes\GPUpgrade\TSProfiles\%~1\windows\Profile.txt"
  6. @ Smiley357, I have close to 200 profiles to target this at, how do I know when it is done?
  7. I tried that and even moved my test folder to the root drive so there wouldn't be any issues with folder names with spaces. Running this code @echo off pause dir C:\GPUpgrade\Test\*.* /b -o:d | find /v "." > c:\dirs.txt for /f "tokens=*" %%a in (c:\dirs.txt) do call :search "%%a" del C:\dirs.txt goto EOF pause :search >>"C:\GPUpgrade\Test\%~1\windows\profile.txt" Find /i "CHGPATH="<"C:\GPUpgrade\Test\%~1\windows\profile.ini" >>"C:\GPUpgrade\Test\%~1\windows\profile.txt" Find /i "CHGCurrentWS="<"C:\GPUpgrade\Test\%~1\windows\profile.ini" >>"C:\GPUpgrade\Test\%~1\windows\profile.txt" Find /i "POSCurrentWS="<"C:\GPUpgrade\Test\%~1\windows\profile.ini" pause Produced this image when run from the command prompt: Edit: Scratch that. It works, it just didn't give me any echo out so I never checked the actual files for comparison. When I did, there were about 50 entries of my search string in the other profile (because I kept running it over and over). One minor glitch though, is there any way to put a space/return line in there? When it copied over the first entry, it put it at the end of the preceeding entry - making them both on the same line. Edit x2. I just added a return character to the template and had it use that as the "spacer". Now it all works. This will be a real time saver. Thank you
  8. Okay, I think I found one that works at eggheadcafe Option Explicit Dim oFSO, sFile1, sFile2, oFile1, oFile2, sText Set oFSO = CreateObject("Scripting.FileSystemObject") sFile1 = "C:\Test\User_057245\windows\profile.txt" sFile2 = "C:\Test\User_057245\windows\profile.ini" Set oFile1 = oFSO.OpenTextFile(sFile1, 1) Set oFile2 = oFSO.OpenTextFile(sFile2, 8) Do While Not oFile1.AtEndOfStream sText = Trim(ofile1.ReadLine) If InStr(sText, "CHGCurrentWS=") <> 0 Then oFile2.WriteLine sText End If If InStr(sText, "POSCurrentWS=") <> 0 Then oFile2.WriteLine sText End If If InStr(sText, "CHGPATH=") <> 0 Then oFile2.WriteLine sText End If Loop That code scanned profile.txt for sText and copied them over to Profile.ini. Now I need to know how to edit that code so that instead of targetting just one user folder, I target something like: C:\test\..\windows\profile.txt >> C:\test..\windows\profile.ini, so that it compares all the user profiles under C:\Test with the .txt and .ini sets in each windows subfolder. I generated a folderlist.ini and a folderlist.txt of all my profiles if that can be called somehow.
  9. I ran that code as this @echo off >>"C:\Documents and Settings\Administrator\My Documents\GPUpgrade\Test\OFASNRAB1\windows\Profile.ini" Find /i "POSCURRENTWS=NRAB1" <"C:\Documents and Settings\Administrator\My Documents\GPUpgrade\Test\OFASNRAB1\windows\Profile.txt" pause And all I got was "press any key to continue"
  10. That might be close. I'll have to run it at work tomorr....later today. One thing though is the batch/script has to be recursive to search through all the subfolders for the .txt and .ini files (keeping them in pairs for each folder). I could do a script to make text entries of all the folder names and make it a filelist.txt of sorts, but I was looking to go a little neater Basically some sort of batch/script that targets a parent folder called Profiles\ and will scan through each Profiles\User1\windows directory and compare profile.txt to profile.ini, copy 3 entries from profile.txt and append them to profile.ini, then do it again for Profiles\User2\Windows, Profiles\User3\Windows, Profiles\User4\Windows, Profiles\User5\Windows, etc. My user names are not as simple as 1, 2, 3, 4, but you get the idea.
  11. I've been tasked to backup and migrate some 600+ user profiles and I'm 2/3 the way there. I've successfully scripted a recursive search that goes through all the user profile subfolders and renames their current profile from .ini to a .txt extension. Second, I've been able to push the new profile template from a single directory to all the userprofile\windows subdirectory. Now I need a script that will go through each user profile folder and copy three text strings from User#\windows\profile.txt and copy them over to the User#\windows\profile.ini. It should read something like this: Open file "D:\Profiles\User1\windows\profile.txt" Search ------Setting1=Entry1 ------Setting2=Entry2 ------Setting3=Entry3 Copy (to temp or clipboard) Close file Open File "D:\Profiles\User1\windows\profile.ini" Paste at end of file (there are some entries in the profile.ini already) ------Setting1=Entry1 ------Setting2=Entry2 ------Setting3=Entry3 Close file Repeat for each profile under "D:\profiles\..\windows\ I have a baseline script which could be way off course, but it can replace specific entries with specifc entries (already definied in the script) when targeting a specific file. Const ForReading = 1 Const ForWriting = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("D:\Profile\User1\windows\Profile.ini", ForReading) strText = objFile.ReadAll objFile.Close strNewText = Replace(strText, "POSDELL", "TextEntry1") Set objFile = objFSO.OpenTextFile("D:\Profile\User1\windows\Profile.ini", ForWriting) objFile.WriteLine strNewText objFile.Close Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("D:\Profile\User1\windows\Profile.ini", ForReading) strText2 = objFile.ReadAll objFile.Close strNewText2 = Replace(strText2, "CHGDELL", "TextEntry2") Set objFile = objFSO.OpenTextFile("D:\Profile\User1\windows\Profile.ini", ForWriting) objFile.WriteLine strNewText2 objFile.Close Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("D:\Profile\User1\windows\Profile.ini", ForReading) strText3 = objFile.ReadAll objFile.Close strNewText3 = Replace(strText3, "COSADELL", "TextEntry3") Set objFile = objFSO.OpenTextFile("D:\Profile\User1\windows\Profile.ini", ForWriting) objFile.WriteLine strNewText3 objFile.Close " That is pretty much an edit I got from The Scripting Guy. To use that one, I made entries in the upgraded profile template for POSDELL, CHGDELL and COSADELL so that the search could target those standard entries and replace them with the entries from the profile.txt.
×
×
  • Create New...