Solved

need assistance with a login script

Posted on 2011-09-19
15
506 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 53

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 53

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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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 53

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 53

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 53

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 53

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 53

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article runs through the process of deploying a single EXE application selectively to a group of user.
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
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 …

785 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