?
Solved

need assistance with a login script

Posted on 2011-09-19
15
Medium Priority
?
510 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 56

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 56

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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

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 56

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 56

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 56

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 56

Accepted Solution

by:
Bill Prew earned 2000 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 56

Expert Comment

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

~bp
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
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 …
Suggested Courses

752 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