Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Registry Value Export into DOS Prompt

Reply
 
Old 11-04-2008   #1 (permalink)
john.renfro


 
 

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
Old 11-04-2008   #2 (permalink)
James Whitlow


 
 

Re: Registry Value Export into DOS Prompt

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

>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
Old 11-04-2008   #3 (permalink)
john.renfro


 
 

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
Old 11-04-2008   #4 (permalink)
john.renfro


 
 

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
Old 11-04-2008   #5 (permalink)
Richard Mueller [MVP]


 
 

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
Old 11-04-2008   #6 (permalink)
Stefan Kanthak


 
 

Re: Registry Value Export into DOS Prompt

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

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

>>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
Quote:

> 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
Old 11-04-2008   #7 (permalink)
James Whitlow


 
 

Re: Registry Value Export into DOS Prompt

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

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

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

>>>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
>
>
Quote:

>> 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
Old 11-05-2008   #8 (permalink)
Stefan Kanthak


 
 

Re: Registry Value Export into DOS Prompt

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

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

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

>>> 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)
Quote:

> 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.
Quote:

> 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
Reply

Thread Tools


Similar Threads
Thread Forum
Script to Export Multiple registry values? VB Script
Export Favorites from Command Prompt Browsers & Mail
Registry Export Not Inserting Into Registry Vista General
using export-csv to export to multiple CSV files PowerShell
Export-CliXml/Export-Csv: Change to Export-Object? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46