The specified path is not valid - powershell

I am in a windows console or powershell. (Windows7 x64 Pro, PowerShell 4)
When i try to type command like "cmd" i have an error message "The specified path is not valid"
PS D:\DevEnv\workspace\api-node> cmd
Microsoft Windows [version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All right reserved.
The specified path is not valid.
What i tryed after reading msdn articles but it don't solve the problem:
-delete my System variable PATH and try again
-clean my registry with ccleaner
Is there any "verbose" or "debug" mode in powershell or windows console to see what path is involved and where i can change it?

Is there any "verbose" or "debug" mode …? I don't think so; however, running next commands from an open cmd window could help to identify possible error source(s):
wmic process where "name='cmd.exe'" get Caption, CommandLine, ParentProcessId, ProcessId
2>NUL reg query "HKLM\Software\Microsoft\Command Processor" /V AutoRun
2>NUL reg query "HKCU\Software\Microsoft\Command Processor" /V AutoRun
In above output we are seeking for any commands which could be a source of The specified path is not valid error message.
wmic seems to be self-explaining;
both reg query show AutoRun registry values (if present), see cmd /?.

Related

Removing regedit key via powershell

I have been removing powershell and/or command line like below. My question is : Is there any equivalent inside powershell for /reg:64 parameter ?
CMD version:
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\TEST /v PropertyToRemove /f /reg:64
powershell version:
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client" -Name "PropertyToRemove"
thanks,
It looks like it's not implemented.
Reading this question: Querying via powershell both 32bit and 64bit registry
it seems you should just be checking whether the os is x32 or x64 first
or run a check if the 64bit registry keys exists
Different topic, same question.. here's stated it's not implemented:
How to access the 64-bit registry from a 32-bit Powershell instance?
look at whenrybruce's reply on the marked answer

Suppress "Try the new cross-platform PowerShell https://aka.ms/pscore6"

I don't mind a bit of Microsoft marketing, but this is annoying when I just want a clean PowerShell prompt. Has anyone found a way of suppressing just the Try the new cross-platform PowerShell https://aka.ms/pscore6 on opening PowerShell, without removing the basic copyright message Windows PowerShell, Copyright (C) Microsoft Corporation. All rights reserved.? I've googled around a lot but found no answer (I know there is a way to suppress everything, but I just want rid of that pscore6 advert only).
Since Windows Terminal 1.0 is released, you can use it instead.
In settings add a flag -NoLogo as shown below:
"list": [
{
// Make changes here to the powershell.exe profile.
"guid": "{61c54bd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe -NoLogo",
"hidden": false
},
You can get rid of the copyright banner by starting powershell from running this in cmd:
Powershell.exe -NoLogo -NoExit
-NoExit is not necessary as #Albin said, and you could create a desktop shortcut/batch file from it.
This message is part of the resource string embedded in Microsoft.PowerShell.ConsoleHost in the ManagedEntranceStrings.resources resource. The full message is
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
This is one string, not two, and there is no logic for picking a different banner.
Because the string is read as a resource, in theory you could create a new resource assembly and put it in C:\Windows\System32\WindowsPowerShell\v1.0\en-US. In practice you can't (even if you'd be willing to put new files in a system directory), because the main assembly is strong-named and installed in the GAC, which means you can't produce a satellite assembly that will load since you don't have the private key required for signing. It does, however, work -- I verified this by building such an assembly with delayed signing, but obviously that's not really a workable idea on a production system.
Replace command line argument in settings.json with this:
"commandline": "powershell.exe -NoLogo -NoExit -Command Write-Host Windows PowerShell`nCopyright `(C`) Microsoft Corporation. All rights reserved.`n",
It disables original text, and writes what we need instead.
If you want to write something else, use `n for new lines, and don't forget to add ` for escaping reserved symbols, like parentheses.
Different language example:
"commandline": "powershell.exe -NoLogo -NoExit -Command Write-Host Windows PowerShell`n`(C`) Корпорация Майкрософт `(Microsoft Corporation`). Все права защищены.`n",
Suppressing messages in IntelliJ IDEA (i.e. WebStorm).
Had the same messages in the terminal windows of my WebStorm.
You can suppress these messages by adding the -NoLogo flag to the Shell Path for the Terminal Emulator.
Go to the settings for configuring the Terminal Emulator by clicking:
File menu -> Settings -> Tools -> Terminal.
Click to confirm editing these settings if needed and then change the Shell path accordingly to:
powershell.exe -NoLogo
When you next time start your IntelliJ IDEA the terminal windows will be clean.
This message means "you are using the old version of powershell". You must update it with commands and software.
When I updated powershell, this message never came again.

bcdedit /copy syntax not correct

I'm trying to run Oracle Virtual Box on my work laptop. I'm getting an error saying that it can't run because I'm running Hyper-v. I'm trying to follow the instructions at Scott Hanselman's Blog, which have worked for me in the past on my personal laptop with a similar issue.
I run:
bcdedit /copy {current} /d "No Hyper V"
The copy command specified is not valid.
Run "bcdedit /?" for command line assistance.
The parameter is incorrect.
I run
bcdedit /copy {current} /d /?
This command creates a copy of the specified boot entry.
bcdedit [/store <filename>] /copy {<id>} /d <description>
<filename> Specifies the store to be used. If this option is not
specified, the system store is used. For more information,
run "bcdedit /? store".
<id> Specifies the identifier of the entry to be copied.
For more information about identifiers, run
"bcdedit /? ID".
<description> Specifies the description to be applied to the new entry.
Example:
The following command creates a copy of the specified operating system boot
entry:
bcdedit /copy {cbd971bf-b7b8-4885-951a-fa03044f5d71} /d "Copy of entry"
and
bcdedit /? ID
IDENTIFIERS
Many of the Bcdedit commands require identifiers. An identifier
uniquely identifies entries contained in the store. An identifier takes the
form of a globally unique identifier, or GUID. A GUID has the following format,
where each "x" represents a hexadecimal digit.
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
For example:
{d2b69192-8f14-11da-a31f-ea816ab185e9}
The position of the dashes (-) and the braces at the beginning and end of the
GUID are required.
Several entries can be identified by well-known identifiers. If an entry has a
well-known identifier, BCDedit displays it in output unless the /v command-line
switch is used. For more information, run "bcdedit /? /v".
The well-known identifiers are as follows:
{bootmgr} Specifies the Windows boot manager entry.
{fwbootmgr} Specifies the firmware boot manager entry,
specifically on systems that implement the
Extensible Firmware Interface (EFI) specification.
{memdiag} Specifies the memory diagnostic application entry.
{ntldr} Specifies a OS loader (Ntldr) that can be used
to start operating systems earlier than Windows
Vista.
{current} Specifies a virtual identifier that corresponds to
the operating system boot entry for the operating
system that is currently running.
but it looks like there's nothing wrong with my syntax, does anyone know what I'm doing wrong?
Powershell seems to have been the problem. In my powershell prompt I typed cmd and then ran bcdedit /copy {current} /d "No Hyper V" with no errors.
bcdedit --% /copy {current} /d "No Hyper V"
stop-parsing symbol --%
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parsing
I had exactly the same problem. I found the solution on this documentation of bcdedit from microsoft. This is just a problem when you are using powershell instead cmd.
You just have to set the identifier of the boot entry into double quotes:
bcdedit /copy "{current}" /d "No Hyper-V"
I had the same problem when the shell/command prompt is not running as administrator.
When not running as administrator, windows does not allow any read or write to BCD
> bcdedit /v
The boot configuration data store could not be opened.
Access is denied.
Running the shell or command prompt as administrator solved the issue.

Win10: How to activate developer mode using powershell or cmd.exe?

I want to activate the developer mode (to use the ubuntu subsystem), but I don't have admin account credentials. However, I have access to a cmd.exe with admin rights. So I can open regedit and use the powershell without restrictions. Some tutorials (this one for example) state that the dev mode can be easily activated by creating or setting special keys in the registry:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock\AllowDevelopmentWithoutDevLicense
In my case these keys did not exist in the registry before, so I added them manually. Sadly, it does not work and dev mode is still inactive. I also tried to open the Settings App using the terminal (start ms-settings:) and enable dev mode using the GUI, but it seems like the start command ignores/flushes the admin previleges and the app asks for credentials.
OS: Win10
Build Version: 14393.1198
EDIT
Because of #magicandre1981 answer, I tried to run the following command
DISM /Online /Add-Capability /CapabilityName:Tools.DeveloperMode.Core~~~~0.0.1.0
But I got this error:
Deployment Image Servicing and Management tool
Version: 10.0.14393.0
Error: 11
You cannot service a running 64-bit operating system with a 32-bit version of DISM.
Please use the version of DISM that corresponds to your computer's architecture.
The DISM log file can be found at C:\WINDOWS\Logs\DISM\dism.log
With the help of google, I found out that I have to use a different cmd.exe version located in C:\\Windows\native. So I navigated there and called cmd.exe. After that I got another error, that the current directory is invalid, but after navigating back to C:\\Windows\System32 the command finished without an error. However, it still does not work. I restarted the system and the dev mode is still not activated.
In the cmd.exe that is running as admin, run the following 2 commands:
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
and
DISM /Online /Add-Capability /CapabilityName:Tools.DeveloperMode.Core~~~~0.0.1.0
Depending on Which Windows 10 Build you run, you may need to reboot the system to finish setup.
To enable the Linux Subsystem, open a cmd.exe as admin and run
DISM /Online /Enable-Feature /FeatureName:Microsoft-Windows-Subsystem-Linux
Once in cmd/admin, run mmc compmgmt.msc and create yourself a user with administrator rights. Log in as that user, pwn.
There are official instructions:
https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging
To enable sideloading:
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowAllTrustedApps" /d "1"
To enable developer mode:
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
Bonus: to enable (outdated) SSH for UWP remote deployment & Windows Device Portal:
dism /Online /Add-Capability /CapabilityName:Tools.DeveloperMode.Core~~~~0.0.1.0
dism /Online /Get-CapabilityInfo /CapabilityName:Tools.DeveloperMode.Core~~~~0.0.1.0
See details about capability here: https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/features-on-demand-non-language-fod?view=windows-10#developer-mode

Getting error while installing "azure-powershell.0.8.7.msi" through .cmd file

I am trying to install “azure-powershell.0.8.7.msi” through a .cmd file using command
msiexec.exe /i ".\azure-powershell.0.8.7.MSI" /passive
This msi file is part of solution explorer(part of project, I have to do it in this way only).
Although I am able to install/uninstall when this msi file when it’s on local disk ( i.e. on some drive)
I tried to log the error it is:
“This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.”
It is a known error of Microsoft. I tried each and every proposed solution on internet but it doesn’t work.
Note: The current user/admin of the system have all the access(read,write,modify).
if your MSI-file is in the same directory like the cmd-file you have to us the following command
msiexec /i "%~dp0azure-powershell.0.8.7.MSI" /qb
%~dp0 is refering to cmd-file directory and in this case to the MSI-file.
If you want to create a log-file use the /l and the logfilepath plus name after /qb.
For example:
msiexec /i "%~dp0azure-powershell.0.8.7.MSI" /qb /l*v %temp%\azure-powershell.log