I'm wondering is there any option via command line to search for a string and export all found keys in Windows registry?
Ex:: If you want to check whether "HKLM\software\etc" key exists.
reg.exe query "HKLM\Software\etc" will return all the subkeys and values in command prompt if found or an error if not found.
ALso, you can directly do
reg.exe export "HKLM\software\etc" "C:\etc.reg"
This will export the registry key and subkeys if found otherwise error if not found.
Powershell has registry iteration capabilities. Start here: http://technet.microsoft.com/en-us/library/ee176841.aspx
export key (with all sub-keys), from CMD (or RUN) i.e.:
regedit /e c:\output.reg "HKEY_LOCAL_MACHINE\System\YourLocation"
p.s. you should run this in CMD with ADMIN PRIVILEGES. for that, right click on START>Run CMD (as Admin)
Related
I ran the command prompt with administrator privilege to uninstall Ananconda on my computer, after the process, I reopened the cmd and found this line, "The system cannot find the path specified" at the beginning of my cmd.
I can guarantee that my cmd did not have this line before, how can I manage to fix it? Is it a serious bug that I should be aware of?
Thank you.
"The system cannot find the path specified."
Open the Registry Editor (Windows key and type regedit in the prompt)
Go to HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun and clear the values.
If it exists in HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun, delete it as well.
Is it possible to make shortcuts so that I can type "cd desk" instead of "cd desktop" to change directory to the desktop? This would only work if desktop is the only folder or file within the current directory that starts with "desk" but I would really like to do this.
No, you can't, but you can use the Tab key to complete the correct name. Pressing Tab multiple time cycles through the matching names existing in the current directory.
See Doskey /?.
You could do this
doskey cddesk=cd "%userprofile%\desktop"
Then type cddesk.
By putting all your macros in a batch file you can autoload. Of course you could do this with batchfiles too.
From Technical Reference to the Windows 2000 Registry, Microsoft, 2000.
AutoRun
HKCU\Software\Microsoft\Command Processor
Data type Range Default value
REG_SZ list of commands There is no default value for this entry.
Description
Contains commands which are executed each time you start Cmd.exe.
Also see this batchfile https://pastebin.com/A2qLw8r3 that list special names.
In a command prompt
start shell:desktop
Or in Start - Run (Winkey + R) just
shell:desktop
I am trying to search a file on remote PC using PSEXEC, however I am getting the above mentioned error.
Can any please suggest any change in the command or some thing else, that can assist in making it work.
Online search suggests that this isn't the issue of PSEXEC, instead is caused by explorer.exe on remote host.
I have added picture of my result. I have tried the command with quotes on file name and without. both have same error.
This command dir exists with code 1 and message "File Not Found".
Because you run cmd with param /c than it return same error code like dir and it is equal 1.
It is correct behaviour.
If you want to find a file, than use command where /r c:\ d.txt. This command was added in Windows 7.
Or use dir /S /P "d.txt" for older OS
Open Registry Editor by pressing windows+r
then type regedit and press enter
now in the search bar paste the below line
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\
If you can see in the picture using the link
Underlined mark is important don't insert any other value in the data of that particular registry.
Here if you filed many registry values then delete all of them except the default one as they are the main reason for the error code 1 shown by the command prompt.
So after removing all of them.
Edit the default registry value and in 'data' insert cmd and save it
Your problem is solved!!
if not then clear the data of the default registry.
It is also easy to use PowerShell and not need psexec.
Invoke-Command HOST01 { & cmd.exe /C dir D:\Users\lit\d.txt }
It should be written in .ps1 scripts with parameter names specified.
Invoke-Command -ComputerName HOST01 -ScriptBlock { & cmd.exe /C dir D:\Users\lit\d.txt }
See also:
help Enable-PSRemoting
help about_Remote
help about_Remote_FAQ
It seems very simple but I couldn't fine a solution for this.
If I open command prompt in Window, It shows directory root like C:\Users\username very first. I wanted to change this because it is not convenient that I need to move to a directory I work every time when I open cmd.
Well,
I tried SET HOMEPATH \Users\username\what I want to go. It kept showing HOMEPATH=\Users\username on cmd screen. I twisted it like opening cmd as administrator and typing SETX HOMEPATH, HOME... trying other stuffs I searched.
but still, I couldn't find way to set a directory root I want to see very first in cmd.
Thank you.
You can
For a concrete change, create a shortcut to open cmd with the desired folder as the default active directory.
For a general change, include in the registry, under HKEY_CURRENT_USER\Software\Microsoft\Command Processor a new REG_SZ value called AutoRun and set its value to cd /d "c:\folder\where\I\work". Any cmd instance created without the /D switch will execute this code.
Or you can create the same value under the registry, but with a REG_EXPAND_SZ type and use as value something like cd /D "%MY_HOME_PATH%", and, of course, ensure the MY_HOME_PATH variable is properly defined before starting the cmd instance.
I am testing a windows driver software. When the test fails, I have to attach registry data to the bug.
I get
"ERROR: Unable to write to the file. There may be a disk or file system error."
when I run the following command
REG EXPORT HKLM\System\CurrentControlSet .\Reg-data\CCS.reg
(I am running the command in Administrator mode).
This happens very infreqently. Can this be caused by driver software? or could this be a generic OS issue?
You are not providing a destination filename to tell REG where to write the exported data to.
C:\>reg export /?
REG EXPORT KeyName **FileName** [/y]
Keyname ROOTKEY[\SubKey] (local machine only).
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key under the selected ROOTKEY.
FileName The name of the disk file to export.
/y Force overwriting the existing file without prompt.
Examples:
REG EXPORT HKLM\Software\MyCo\MyApp AppBkUp.reg
Exports all subkeys and values of the key MyApp to the file AppBkUp.reg
I ran into the same problem when calling "reg export" (followed by a registry key and a path to write to) from a CMD file. The exact same command consistently worked when pasted to the same CMD prompt where the cmd script was run from, and consistently did not work from within the script.
I couldn't find the reason, but I worked around the problem by replacing "reg export" with "regedit /e", beware that you need to switch the position of the file path and registry key. This command works both inside and outside a cmd script.
So, here is before and after:
::reg export /y HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318} "%temp%\myfilename"
regedit /e /y "%temp%\myfilename" HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}
PS. Both commands will create a file in UTF16 format.
To make it short, it should be:
Reg Export "HKCU\SOFTWARE\Microsoft\Windows\Shell\Bags" "G:\reg\Shell_Bags.reg"