Solved

need assistance with a login script

Posted on 2011-09-19
15
504 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
  • 8
  • 7
15 Comments
 
LVL 51

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 51

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
 

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 51

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 51

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 51

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 51

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 51

Expert Comment

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

~bp
0

Join & Write a Comment

Introduction You may have a need to setup a group of users to allow local administrative access on workstations.  In a domain environment this can easily be achieved with Restricted Groups and Group Policies. This article will demonstrate how to…
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now