Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: How to put command with parms directly in Registry RunOnce?

25 Mar 2015   #1
pstein

win7pro 64bit
 
 
How to put command with parms directly in Registry RunOnce?

Assume I want to perform a command line command with parameters one time at next boot (under 64bit Win 7).

Therefore I want to create this command directly in the appropriate Registy key and not indirectly by
putting it into *.bat batch script and and call this from RunOnce

For simplicity assume I want to perform a "chkdsk" command but it could be others as well.

Now I have difficulties to setup a *.reg script. The following does NOT work:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\RunOnce]
"doitonce"="\"chkdsk Z: /F /V /R /I /C >C:\log\mychkdsk.log\""

What do I have to change?

Peter


My System SpecsSystem Spec
.
25 Mar 2015   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Hello Pstein,

Quote   Quote: Originally Posted by pstein View Post
What do I have to change?
Quite a bit. You're experiencing multiple problems currently.

For starters, there are mistakes with your example reg snippet, namely, there's a pair of literal double quotes around the whole command, which is incorrect because you are telling the parser to treat the whole line as a single path to a program instead of a program to run with arguments. Secondly, to use a literal backslash you must escape a backslash by backslash-ing a backslash. Last problem about your .reg file is that you are missing the Windows Registry Editor Version 5.00 shebang line at the top of your file. This line is mandatory.

This is what your not-working .reg file should have looked like
Code:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\RunOnce]
"doitonce"="chkdsk Z: /F /V /R /I /C >C:\\log\\mychkdsk.log"

Now for the more problematic problem: you cannot use redirection outside of a Command Prompt. So you must instruct the Command Prompt to interpret this command by preceding the command line command you want to run with cmd /c.

E.g.
Code:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\RunOnce]
"doitonce"="cmd /c \"chkdsk Z: /F /V /R /I /C >C:\\log\\mychkdsk.log\""

Also, if something "does not work", please be specific. Are you receiving an error of any kind?
My System SpecsSystem Spec
26 Mar 2015   #3
pstein

win7pro 64bit
 
 

Great. Thank you
My System SpecsSystem Spec
.

Reply

 How to put command with parms directly in Registry RunOnce?




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
backup registry in command line
Hello I am trying to back up a registry key, I am using the command >reg export hkey_local_machine\software\microsoft\windows c:\windows\regbackup and I keep getting the error message Unable to write to the file. There may be a disk or file system error. Not sure what I am doing wrong, any ...
Backup and Restore
Cannot change an IP address other than directly editing the registry
Hi, all. I have run into a situation I wish I knew how to get out of. One of my systems won't allow me to change the IP address (static) or use ipconfig /renew to pull a new one via DHCP (dynamic). If I try to change IPv4 settings, every time I try, it wants me to reboot the machine, and this...
Network & Sharing
How can I set this via command-line or registry?
How can I set this via command-line or registry? I need a way to automatically launch "Explorer c:\folder\myfolder" with a view appropriate for long filenames on any Windows Vista/Win7 PC.
Customization
Registry Editing from Command Line
So I am trying to delete some keys from the registry using command line, eventually I am going to turn it into a batch file because it is something I may have to do frequently. Basically I want to delete a folder full of registry keys without having to list every key individually. Anyone have an...
General Discussion
Command line Registry Permission
I found a lot of articles on how to gain full control over a registry key but nothing worked for me. So guys can you help Me?
General Discussion
Visual Performance Through Registry or Command?
Hey. I was just wondering if there is a way to set the Visual Performance Settings through either the Registry or the Command Prompt? What I mean by Visual Performance Settings is like the settings that you can choose to turn on or off Aero Peek, Aero Shake etc.. If there is no a way to do...
Customization


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 05:36.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App