Windows Vista Forums

Registry Value Export into DOS Prompt
  1. #1


    john.renfro Guest

    Registry Value Export into DOS Prompt

    I want to export a registry key value and then use the value in a
    command prompt. I need to export the value of this key:

    HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Security
    \OutlookSecureTempFolder

    And then put that value into a command:

    del "value"\*.* /q

    This will clear out the Outlook temp folder as we have some people in
    my company having issues where they are unable to open PDF files or
    pictures do not show up and deleting all the files in this folder
    solves the issue. I have no real experience with scripting but can
    manage for the most part. Can anyone help?



      My System SpecsSystem Spec

  2. #2


    James Whitlow Guest

    Re: Registry Value Export into DOS Prompt

    <john.renfro@xxxxxx> wrote in message
    news:99db9eb6-55f3-424d-bb07-87fef64a6b93@xxxxxx

    >I want to export a registry key value and then use the value in a
    > command prompt. I need to export the value of this key:
    >
    > HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Security
    > \OutlookSecureTempFolder
    >
    > And then put that value into a command:
    >
    > del "value"\*.* /q
    >
    > This will clear out the Outlook temp folder as we have some people in
    > my company having issues where they are unable to open PDF files or
    > pictures do not show up and deleting all the files in this folder
    > solves the issue. I have no real experience with scripting but can
    > manage for the most part. Can anyone help?
    Give the below code a try

    Set oWSH = CreateObject("WScript.Shell")
    sOutSecTmp = oWSH.RegRead("HKCU\Software\Microsoft\Office\11.0" _
    & "\Outlook\Security\OutlookSecureTempFolder")
    If Len(sOutSecTmp) = 0 Then WScript.Quit 'Make sure var isn't empty
    oWSH.Run "%comspec% /c del """ & sOutSecTmp & "\*.*"" /q", 0, False



      My System SpecsSystem Spec

  3. #3


    john.renfro Guest

    Re: Registry Value Export into DOS Prompt

    So do I create an empty text file, paste this in it and rename to
    something.vbs like I would a batch file? I have no scripting knowledge
    but am pretty good with batch files. I also found this example of the
    same thing but in a batch file but cannot get it to work either.

    REM OLK_PURGER.BAT by Inferno999
    REM This batch file will Scan the registry for all SecureTempFolder
    locations
    REM and purge found folders, allowing room for temp items to be
    created.
    REM Each query returns errorlevel 1 if the key is not found or a 0 if
    it is,
    REM at which point it deletes the referenced location.

    @echo off
    SetLocal EnableDelayedExpansion
    for /f %%Q in ($B!I(B12$B!m(B,$B!I(B11$B!m(B,$B!I(B10$B!m(B,$B!I(B9$B!m(B) do (
    REG QUERY HKEY_CURRENT_USER\Software\Microsoft\Office\%%Q.0
    ECHO !ErrorLevel!
    IF !ErrorLevel!==0 (
    for /f $B!H(Btokens=2,*$B!I(B %%a in ($B!G!I(Breg query HKEY_CURRENT_USER\Software
    \Microsoft\Office\12.0\Outlook\Security /v OutlookSecureTempFolder|
    find $B!H(BOutlookSecureTempFolder$B!I(B $B!H!F(B) do (
    rmdir /s /q $B!H(B%%b$B!I(B
    )
    )
    )
    EndLocal

    This batch file returns an error 2 was unexpected at this time. Any
    ideas on this batch file or can you direct me to running the script
    you provided? Also, I need to modify this to run for 12.0 as well as
    the 11.0 folder in the registry which covers Outlook 2003 and Outlook
    2007. Thanks!

      My System SpecsSystem Spec

  4. #4


    john.renfro Guest

    Re: Registry Value Export into DOS Prompt

    Nevermind! It does work great and thank you so much!

    The problem is my test machine only has one file in there and it was
    read-only so I have to add /f to the command. I also manipulated it
    for both Outlook 2003 and 2007. Thanks again!

      My System SpecsSystem Spec

  5. #5


    Richard Mueller [MVP] Guest

    Re: Registry Value Export into DOS Prompt

    Paste the VBScript code into a text file with *.vbs extension. You can use
    Notepad. Most administrative scripts are run at a command prompt with
    cscript. For example, if the VBScript program is saved in a file called
    Example.vbs, the command could be:

    cscript Example.vbs

    This assumes you are in the folder where the file Example.vbs is saved.
    Otherwise, you must include the path to the file. You should also be able to
    run the program by clicking on the *.vbs file in Windows Explorer. The file
    association for *.vbs files should be one of the host program for VBScript,
    either cscript.exe or wscript.exe. For this example, either host should work
    fine. Cscript is designed for the command console, wscript provides a GUI
    interface.

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

  6. #6


    Stefan Kanthak Guest

    Re: Registry Value Export into DOS Prompt

    "James Whitlow" <jwhitlow.60372693@xxxxxx> wrote:

    > <john.renfro@xxxxxx> wrote in message
    > news:99db9eb6-55f3-424d-bb07-87fef64a6b93@xxxxxx

    >>I want to export a registry key value and then use the value in a
    >> command prompt. I need to export the value of this key:
    >>
    >> HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Security
    >> \OutlookSecureTempFolder
    >>
    >> And then put that value into a command:
    >>
    >> del "value"\*.* /q

    > Give the below code a try
    >
    > Set oWSH = CreateObject("WScript.Shell")
    > sOutSecTmp = oWSH.RegRead("HKCU\Software\Microsoft\Office\11.0" _
    > & "\Outlook\Security\OutlookSecureTempFolder")
    > If Len(sOutSecTmp) = 0 Then WScript.Quit 'Make sure var isn't empty
    > oWSH.Run "%comspec% /c del """ & sOutSecTmp & "\*.*"" /q", 0, False
    Why do you mix WSH and CMD? Instead of oWSH.Run ... better use

    With CreateObject("Scripting.FileSystemObject")
    .DeleteFile(.BuildPath(sOutSecTmp, "*"))
    End With

    Stefan
    [
    --
    Die unaufgeforderte Zusendung werbender E-Mails verstoesst gegen §823
    Abs. 1 sowie §1004 Abs. 1 BGB und begruendet Anspruch auf Unterlassung.
    Beschluss des OLG Bamberg vom 12.05.2005 (AZ: 1 U 143/04)



      My System SpecsSystem Spec

  7. #7


    James Whitlow Guest

    Re: Registry Value Export into DOS Prompt

    "Stefan Kanthak" <postmaster@[127.0.0.1]> wrote in message
    news:uihY%23KsPJHA.576@xxxxxx

    > "James Whitlow" <jwhitlow.60372693@xxxxxx> wrote:
    >

    >> <john.renfro@xxxxxx> wrote in message
    >> news:99db9eb6-55f3-424d-bb07-87fef64a6b93@xxxxxx

    >>>I want to export a registry key value and then use the value in a
    >>> command prompt. I need to export the value of this key:
    >>>
    >>> HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\O utlook\Security
    >>> \OutlookSecureTempFolder
    >>>
    >>> And then put that value into a command:
    >>>
    >>> del "value"\*.* /q
    >
    >

    >> Give the below code a try
    >>
    >> Set oWSH = CreateObject("WScript.Shell")
    >> sOutSecTmp = oWSH.RegRead("HKCU\Software\Microsoft\Office\11.0" _
    >> & "\Outlook\Security\OutlookSecureTempFolder")
    >> If Len(sOutSecTmp) = 0 Then WScript.Quit 'Make sure var isn't empty
    >> oWSH.Run "%comspec% /c del """ & sOutSecTmp & "\*.*"" /q", 0, False
    >
    > Why do you mix WSH and CMD? Instead of oWSH.Run ... better use
    >
    > With CreateObject("Scripting.FileSystemObject")
    > .DeleteFile(.BuildPath(sOutSecTmp, "*"))
    > End With
    I was tailoring the code to the request from the OP. He specifically asked
    to have a value inserted into a specific dos command. Also, the dos command
    does not abort the script on a locked file, as the 'DeleteFile' method of
    'Scripting.FileSystemObject' does.



      My System SpecsSystem Spec

  8. #8


    Stefan Kanthak Guest

    Re: Registry Value Export into DOS Prompt

    "James Whitlow" <jwhitlow.60372693@xxxxxx> wrote:

    > "Stefan Kanthak" <postmaster@[127.0.0.1]> wrote in message
    > news:uihY%23KsPJHA.576@xxxxxx

    >> "James Whitlow" <jwhitlow.60372693@xxxxxx> wrote:

    >>> Give the below code a try
    >>>
    >>> Set oWSH = CreateObject("WScript.Shell")
    >>> sOutSecTmp = oWSH.RegRead("HKCU\Software\Microsoft\Office\11.0" _
    >>> & "\Outlook\Security\OutlookSecureTempFolder")
    >>> If Len(sOutSecTmp) = 0 Then WScript.Quit 'Make sure var isn't empty
    >>> oWSH.Run "%comspec% /c del """ & sOutSecTmp & "\*.*"" /q", 0, False
    >>
    >> Why do you mix WSH and CMD? Instead of oWSH.Run ... better use
    >>
    >> With CreateObject("Scripting.FileSystemObject")
    >> .DeleteFile(.BuildPath(sOutSecTmp, "*"))
    >> End With
    or just (see MSKB 296115 or 817878)

    CreateObject("Scripting.FileSystemObject").DeleteFolder(sOutSecTmp, vbTrue)

    > I was tailoring the code to the request from the OP. He specifically asked
    > to have a value inserted into a specific dos command.
    Not every "request" makes sense.
    The OP is apparently a newbie and thus probably not aware of the FSO
    and its methods.

    > Also, the dos command
    > does not abort the script on a locked file, as the 'DeleteFile' method of
    > 'Scripting.FileSystemObject' does.
    Correct.
    CMD.EXE's built-in DEL/ERASE but won't delete locked* file(s) too, so
    one of the OP's goals (deleting all the files in this folder) is not
    achieved in either case.

    * and "read-only" files if the option /F is not given

    Stefan


      My System SpecsSystem Spec

Registry Value Export into DOS Prompt problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Entire SBS 2003 Registry techieg SBS Server 6 23 Aug 2009
Script to Export Multiple registry values? Ryan VB Script 2 11 Jul 2009
Export Favorites from Command Prompt TimD8463 Browsers & Mail 1 05 Dec 2008
Registry Export Not Inserting Into Registry JamesJ Vista General 11 13 Sep 2008
Export-CliXml/Export-Csv: Change to Export-Object? Alex K. Angelopoulos [MVP] PowerShell 3 04 Jun 2006