Solved

need assistance with a login script

Posted on 2011-09-19
15
508 Views
Last Modified: 2012-05-12
can someone provide a script that will rename the following files located in this location:
C:\Users\Joe_Smith\AppData\Local\Microsoft\Communicator\sip_Joe.Smith@mydomain.com

files to rename:
GalContacts.db
GalContacts.db.idx

rename to *.old

for widows xp / 2003 the location would be:
C:\Documents and Settings\joe_smith\Local Settings\Application Data\\Microsoft\Communicator\sip_Joe.Smith@mydomain.com

thanks in advance!

S.
0
Comment
Question by:siber1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 54

Expert Comment

by:Bill Prew
ID: 36564188
Not sure exactly what you are after here, can you explain further?  The basic renames would be something like:

if exist "C:\Users\Joe_Smith\AppData\Local\Microsoft\Communicator\sip_Joe.Smith@mydomain.com\GalContacts.db"     ren "C:\Users\Joe_Smith\AppData\Local\Microsoft\Communicator\sip_Joe.Smith@mydomain.com\GalContacts.db"     "GalContacts.db.old"
if exist "C:\Users\Joe_Smith\AppData\Local\Microsoft\Communicator\sip_Joe.Smith@mydomain.com\GalContacts.db.idx" ren "C:\Users\Joe_Smith\AppData\Local\Microsoft\Communicator\sip_Joe.Smith@mydomain.com\GalContacts.db.idx" "GalContacts.db.idx.old"

if exist "C:\Documents and Settings\joe_smith\Local Settings\Application Data\Microsoft\Communicator\sip_Joe.Smith@mydomain.com\GalContacts.db"     ren "C:\Documents and Settings\joe_smith\Local Settings\Application Data\Microsoft\Communicator\sip_Joe.Smith@mydomain.com\GalContacts.db"     "GalContacts.db.old"
if exist "C:\Documents and Settings\joe_smith\Local Settings\Application Data\Microsoft\Communicator\sip_Joe.Smith@mydomain.com\GalContacts.db.idx" ren "C:\Documents and Settings\joe_smith\Local Settings\Application Data\Microsoft\Communicator\sip_Joe.Smith@mydomain.com\GalContacts.db.idx" "GalContacts.db.idx.old"

Open in new window

But I suspect you may want to leverage LOCALAPPDATA and APPDATA system variables?  And that the username will change from system to system?

~bp
0
 

Author Comment

by:siber1
ID: 36564301
hi Bill, yes thanks. the part that i'm not sure how to script is the SIP profile for each user will be different. for example all users have firstname.lastname@domain.com as their signin ID. so the directory would be
C:\Users\Joe_Smith\AppData\Local\Microsoft\Communicator\sip_Joe.Smith@mydomain.com

perhaps the better way to approach it would be to search for these files under the root directory:
C:\Users\Joe_Smith\AppData\Local\Microsoft\Communicator

search for:
GalContacts.db
GalContacts.db.idx

and rename if found. can you provide an updated script for this?

many thanks!
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 36564333
See if this helps / makes sense.

if defined LOCALAPPDATA (
  REM Win7, Vista
  call :DoRename "%LOCALAPPDATA%"
) else (
  if defined APPDATA (
    REM Older versions of Windows
    call :DoRename "%APPDATA%"
  )
)
goto :EOF

:DoRename [folder]
  REM Search all subfolders of the one passed in
  for /D /R "%%~1" %%A in (*) do (
    REM If we find the database fiels, rename them
    if exist "%%~A\GalContacts.db" (
      ren "%%~A\GalContacts.db" ren "%%~A\GalContacts.db" "GalContacts.db.old"
      ren "%%~A\GalContacts.db.idx" ren "%%~A\GalContacts.db.idx" "GalContacts.db.idx.old"
    )
  )
  goto :EOF

Open in new window

~bp
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:siber1
ID: 36564386
hi Bill, can we specify a more exact path in the script?
%localappdata%\\Microsoft\Communicator\

when i run it as a .bat file it doesnt rename the file, can i set a break on the file to see where it is failing?

thx
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 36564402
Give this a try.  It looked like I made a cut and paste error on the REN lines above.  But I added a couple of ECHO statements in here too for debug info.

if defined LOCALAPPDATA (
  REM Win7, Vista
  call :DoRename "%LOCALAPPDATA%"
) else (
  if defined APPDATA (
    REM Older versions of Windows
    call :DoRename "%APPDATA%"
  )
)
goto :EOF

:DoRename [folder]
  REM Search all subfolders of the one passed in
  for /D /R "%%~1\Microsoft\Communicator" %%A in (*) do (
    ECHO Searching folder "%%A"
    REM If we find the database fiels, rename them
    if exist "%%~A\GalContacts.db" (
      ECHO Found database in "%%A"
      ren "%%~A\GalContacts.db" "GalContacts.db.old"
      ren "%%~A\GalContacts.db.idx" "GalContacts.db.idx.old"
    )
  )
  goto :EOF

Open in new window

~bp
0
 

Author Comment

by:siber1
ID: 36564418
thx. is there a way to pause it? i tried adding the pause statement so i coudl see the error.
0
 

Author Comment

by:siber1
ID: 36564447
added the pause statement, not seeing any error howerver the files are not renamed.
0
 

Author Comment

by:siber1
ID: 36564879
hi Bill, script is not renaming the files in that directory. any ideas?

thx
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 36566150
What did the ECHO statements that we added display?

~bp
0
 

Author Comment

by:siber1
ID: 36569593
hi Bill, here are the echo results:
ECHO Searching folder "%A"
 REM If we find the database fiels, rename them
 if exist "%~A\GalContacts.db" (
ECHO Found database in "%A"
 ren "%~A\GalContacts.db" "GalContacts.db.old"
 ren "%~A\GalContacts.db.idx" "GalContacts.db.idx.old"
)

however the file is not renamed.
0
 

Author Comment

by:siber1
ID: 36582293
any update on this?
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 36584247
hi Bill, here are the echo results:
ECHO Searching folder "%A"
 REM If we find the database fiels, rename them
 if exist "%~A\GalContacts.db" (
ECHO Found database in "%A"
 ren "%~A\GalContacts.db" "GalContacts.db.old"
 ren "%~A\GalContacts.db.idx" "GalContacts.db.idx.old"
)
I didn't understand what these were, they look like a copy of the script code, not the output  when it ran.

~bp
0
 
LVL 54

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 36584294
Also, I see one other problem, change this line:

  for /D /R "%%~1\Microsoft\Communicator" %%A in (*) do (


to:

  for /D /R "%~1\Microsoft\Communicator" %%A in (*) do (

~bp
0
 

Author Closing Comment

by:siber1
ID: 36585095
thx worked. thx Bill!
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 36586280
Great, glad that helped.

~bp
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question