Can reg files be merged silently?

  • Thread starter Thread starter Lemon Jelly
  • Start date Start date
L

Lemon Jelly

Hi
I run a pair of reg files that have shortcuts to my Desktop that toggle
the Picture & Fax Viewer. Each time I run either, I have to click on two
dialogue boxes. I can run batch files silently (eg regsvr32 /u /s
shimgvw.dll) that will do it but it also disables thumbnail view icons.
 
Thanks David, the question is in the subject line. A further one if I
may. Can I restrict silent mode to just these two reg files?

I can edit the .reg extension under File Types by adding the /s switch
but this is global & potentially dangerous, adding /s to the shortcut
either inside or outside the quotes doesn't seem to work. I got around
this for the moment by creating a new file extension for any reg files I
want to run silently but wonder if there's a simpler method.

That's nice. What's your actual question? Regedit also does a /s
 
Make shortcuts
regedit /s c:\myregfile.reg

Making custom filetypes sounds a good idea.

I'd do shortcut if likely to be only those two but a custom filetype if I was going to be doing a lot of it.

A script file can also work.

Here's a snippett from the beginning of all my scripts
Set Sh = WScript.CreateObject("WScript.Shell")
Sh.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\MRUList","some value"

This writes "some value" to the value named MRUList

To write to a keys default value use a trailing back slash, eg
Sh.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU\", "some value"

Here's the docs

Creates a new key, adds another value-name to an existing key (and assigns it a value), or changes the value of an existing value-name.

object.RegWrite(strName, anyValue [,strType])
Arguments
object
WshShell object.
strName
String value indicating the key-name, value-name, or value you want to create, add, or change.
anyValue
The name of the new key you want to create, the name of the value you want to add to an existing key, or the new value you want to assign to an existing value-name.
strType
Optional. String value indicating the value's data type.
Remarks
Specify a key-name by ending strName with a final backslash. Do not include a final backslash to specify a value name. The RegWrite method automatically converts the parameter anyValue to either a string or an integer. The value of strType determines its data type (either a string or an integer). The options for strType are listed in the following table.

Converted to strType
String REG_SZ
String REG_EXPAND_SZ
Integer REG_DWORD
Integer REG_BINARY

Note The REG_MULTI_SZ type is not supported for the RegWrite method.
Tip RegWrite will write at most one DWORD to a REG_BINARY value. Larger values are not supported with this method.
Fully qualified key-names and value-names are prefixed with a root key. You may use abbreviated versions of root key names with the RegWrite method. The five root keys are listed in the following table.

Root key Name Abbreviation
HKEY_CURRENT_USER HKCU
HKEY_LOCAL_MACHINE HKLM
HKEY_CLASSES_ROOT HKCR
HKEY_USERS HKEY_USERS
HKEY_CURRENT_CONFIG HKEY_CURRENT_CONFIG

The four possible data types you can specify with strType are listed in the following table.

Type Description In the Form of
REG_SZ A string A string
REG_DWORD A number An integer
REG_BINARY A binary value An integer
REG_EXPAND_SZ An expandable string
(e.g., "%windir%\\calc.exe") A string

Example
The following code creates a key and two values, reads them, and deletes them.

[VBScript]
Dim WshShell, bKey
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\", 1, "REG_BINARY"
WshShell.RegWrite "HKCU\Software\ACME\FortuneTeller\MindReader", "Goocher!", "REG_SZ"

bKey = WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\")
WScript.Echo WshShell.RegRead("HKCU\Software\ACME\FortuneTeller\MindReader")

WshShell.RegDelete "HKCU\Software\ACME\FortuneTeller\MindReader"
WshShell.RegDelete "HKCU\Software\ACME\FortuneTeller\"
WshShell.RegDelete "HKCU\Software\ACME\"
[JScript]
var WshShell = WScript.CreateObject("WScript.Shell");

WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\", 1, "REG_BINARY");
WshShell.RegWrite ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader", "Goocher!", "REG_SZ");

var bKey = WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\");
WScript.Echo (WshShell.RegRead ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader"));

WshShell.RegDelete ("HKCU\\Software\\ACME\\FortuneTeller\\MindReader");
WshShell.RegDelete ("HKCU\\Software\\ACME\\FortuneTeller\\");
WshShell.RegDelete ("HKCU\\Software\\ACME\\");
See Also
WshShell Object | RegDelete Method | RegRead Method
 
David Candy - typed:
Make shortcuts
regedit /s c:\myregfile.reg

Doh, of course! That simple. If I'd remembered that, I'd have not
thought further & created a new file type. As you say, any further reg
files which I'd like to run silently now just need the new extension.

Also thanks for the scripting info. Having just got into scripts with
PSP8 with great success, XP scripting is looking enticing - shame it
doesn't have a macro recorder.
 
But you can use scripting as a macro playback for keystrokes.

There are two ways of playing keystrokes

One is to get Windows Recorder supplied with Windows 3.1, the other is to write a script.

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "%{TAB}^c%{TAB}^v"
[above sends Alt + Tab, Ctrl + C, Alt + Tab, then Ctrl + V]

Then set a shortcut to the scripts and set a hotkey for the shortcut (see help)


Windows Script Host

SendKeys Method
See Also
WshShell Object | Run Method

Sends one or more keystrokes to the active window (as if typed on the keyboard).

object.SendKeys(string)
Arguments
object
WshShell object.
string
String value indicating the keystroke(s) you want to send.
Remarks
Use the SendKeys method to send keystrokes to applications that have no automation interface. Most keyboard characters are represented by a single keystroke. Some keyboard characters are made up of combinations of keystrokes (CTRL+SHIFT+HOME, for example). To send a single keyboard character, send the character itself as the string argument. For example, to send the letter x, send the string argument "x".

Note To send a space, send the string " ".
You can use SendKeys to send more than one keystroke at a time. To do this, create a compound string argument that represents a sequence of keystrokes by appending each keystroke in the sequence to the one before it. For example, to send the keystrokes a, b, and c, you would send the string argument "abc". The SendKeys method uses some characters as modifiers of characters (instead of using their face-values). This set of special characters consists of parentheses, brackets, braces, and the:

a.. plus sign "+",
b.. caret "^",
c.. percent sign "%",
d.. and tilde "~"
Send these characters by enclosing them within braces "{}". For example, to send the plus sign, send the string argument "{+}". Brackets "[ ]" have no special meaning when used with SendKeys, but you must enclose them within braces to accommodate applications that do give them a special meaning (for dynamic data exchange (DDE) for example).

a.. To send bracket characters, send the string argument "{[}" for the left bracket and "{]}" for the right one.
b.. To send brace characters, send the string argument "{{}" for the left brace and "{}}" for the right one.
Some keystrokes do not generate characters (such as ENTER and TAB). Some keystrokes represent actions (such as BACKSPACE and BREAK). To send these kinds of keystrokes, send the arguments shown in the following table:

Key Argument
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}

To send keyboard characters that are comprised of a regular keystroke in combination with a SHIFT, CTRL, or ALT, create a compound string argument that represents the keystroke combination. You do this by preceding the regular keystroke with one or more of the following special characters:

Key Special Character
SHIFT +
CTRL ^
ALT %

Note When used this way, these special characters are not enclosed within a set of braces.
To specify that a combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, create a compound string argument with the modified keystrokes enclosed in parentheses. For example, to send the keystroke combination that specifies that the SHIFT key is held down while:

a.. e and c are pressed, send the string argument "+(ec)".
b.. e is pressed, followed by a lone c (with no SHIFT), send the string argument "+ec".
You can use the SendKeys method to send a pattern of keystrokes that consists of a single keystroke pressed several times in a row. To do this, create a compound string argument that specifies the keystroke you want to repeat, followed by the number of times you want it repeated. You do this using a compound string argument of the form {keystroke number}. For example, to send the letter "x" ten times, you would send the string argument "{x 10}". Be sure to include a space between keystroke and number.

Note The only keystroke pattern you can send is the kind that is comprised of a single keystroke pressed several times. For example, you can send "x" ten times, but you cannot do the same for "Ctrl+x".
Note You cannot send the PRINT SCREEN key {PRTSC} to an application.
Example
The following example demonstrates the use of a single .wsf file for two jobs in different script languages (VBScript and JScript). Each job runs the Windows calculator and sends it keystrokes to execute a simple calculation.

<package>
<job id="vbs">
<script language="VBScript">
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 100
WshShell.SendKeys "1{+}"
WScript.Sleep 500
WshShell.SendKeys "2"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 500
WshShell.SendKeys "*3"
WScript.Sleep 500
WshShell.SendKeys "~"
WScript.Sleep 2500
</script>
</job>

<job id="js">
<script language="JScript">
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("calc");
WScript.Sleep(100);
WshShell.AppActivate("Calculator");
WScript.Sleep(100);
WshShell.SendKeys ("1{+}");
WScript.Sleep(500);
WshShell.SendKeys("2");
WScript.Sleep(500);
WshShell.SendKeys("~");
WScript.Sleep(500);
WshShell.SendKeys("*3");
WScript.Sleep(500);
WshShell.SendKeys("~");
WScript.Sleep(2500);
</script>
</job>
</package>
See Also
WshShell Object | Run Method
 
David Candy - typed:
But you can use scripting as a macro playback for keystrokes.

There are two ways of playing keystrokes

One is to get Windows Recorder supplied with Windows 3.1, the other
is to write a script.

Thanks, you cram in so much info, I usually archive your replies! God be
with you, David.
 
Thank you for that. I spent the day in the children's intensive care ward. My niece is responding a little bit but will be critical for 1 to 6 months. My sister has at last been identified and the coroner should release her tomorrow.

Lethal electrics and faulty smoke detectors need to be stamped out in rental properties. Once we finish Di's cremation (I wanted a burial so as not to help Mr Fire but overruled by parents) we start on making sure that something is done.

My dad has cremated his mum, only brother, and now daughter in the last six months. I gave him a computer three weeks ago so he could find some interest in life (Di and dad were/are bonsai artists and business partners - I envisgaged them instant messaging each other) as he was withdrawing from all his social contacts as he's quite sick.
 
Thanks for sharing David - it can take guts to do so & has helped me put
my own current difficulties & a long term health issue in perspective.

David Candy - typed:
 
One thing is that we all bear our own crosses. I've made 20 years of life with a potential lethal illness. And 40s is kind to noone. As I heard a lass I know share recently - I have things growing on me. And so do I.

I was talking to someone tonight, who was overwhelmed by my story, so I reminded them that their story is important too. And that their story is more important to them than my story.
 
Back
Top