Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

need assistance with a login script

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

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 58

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 58

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 58

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 58

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 58

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 58

Expert Comment

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

~bp
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

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 process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

618 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