How for the life of me can I pass a space at the windows command line that happens to be in a folder name? When I remove the space from the folder name, I can execute a directory copy. I've googled escaping spaces, etc., but I just haven't hit on it yet.
Thanks for your help on this one!
Using quotations will solve this issue. Here is an example.
C:\Users\Administrator>copy "C:\users\Administrator\desktop\new folder" "C:\users\Administrator"
The command completed successfully.
C:\Users\Administrator>
I hope this helps.
Related
Whenever I open Windows Powershell I see this
powershell error message. It seems to me that every time I open Powershell it attempts to run conda.exe from a TEMP folder that no longer exists on my machine. Furthermore, when I open command prompt I see this error, so I'm guessing it's doing the same thing there.
I've checked my user and system path variables and there is no mention of the temp path that is listed in the powershell error. Any help with this would be greatly appreciated!
When such a thing happens, it's most likely because of your PowerShell $Profile, that is always loaded on startup.
Check the file, see if it exists and what's inside it. If you still got issues after that, let us know.
I've added an option to copy a proper UNC path to the context menu of all directories via PowerShell.
Edit:
I didn't mention that I'm actually using two different keys: One to copy the UNC of the current directory, and one to copy it from a different directory. I didn't think it would make a difference, but it does.
End Edit
Currently, the key value is as follows:
powershell.exe -WindowStyle Hidden -Command . <path I have to censor>\Save-To-Clipboard.ps1 \"%L%\"
Expected behaviour:
The PowerShell script is run quietly.
Actual behaviour:
A PowerShell Window pops up and closes itself.
The same thing happens with cmd.
I've tried using a VBS wrapper as well, but it needs the current path as an argument, which I can't figure out how to do. Simply putting it after the filename as you would in the command line results in the error:
This file does not have an app associated with it for performing this
action. Please install an app or, if one is already installed, create
an association in the Default Apps settings page.
Key value here:
<path I have to censor>\ClunkyWrapper.vbs \"%L%\"
Admittedly, this is my first time running a command from a registry key, and I can't seem to find any resources about this topic. (I might just not know what exactly to google for.) So I would be thankful for more general information on how to run commands from registry keys as well.
Okay, I found a way.
First of all, apparently whether you need to use %L% or %V% depends on the key. I can't tell you why, unfortunately.
That solves the error message of the VBA script, but it still wouldn't run like this.
So I then used wscript.exe, and it finally worked.
wscript.exe <secret path>\ClunkyWrapper.vbs "%V%"
I am running into a bit of a problem when attempting to use Powershell with NRPE. Now I ran this command,
command[alias_check_commerce_log]=cmd /c echo C:\Program Files\nrpe\plugins\file_checker.ps1; exit($LastExitCode) | powershell.exe -command -
in cmd and it went through without a hitch. Just when I call it via Icinga, for some odd reason, it spits out 'powershell.exeA' is not recognized as an internal or external command. Now I know the A is not supposed to be sitting with powershell.exe, so how would I keep this from happening? Keep in mind that the command is the same in the config as posted here. Checked all text in hopes of it just being a simple Typo. I just can't seem to wrap my head around this one and figure out how to keep this from happening. Any and all help is appreciated, thank you.
Probably file encoding. You likely copy/pasted the command line from a web site or something, and there is a special character after .exe.
Open the file where that command is defined in an editor that supports different encodings and hopefully one that can show whitespace and "special" characters, and inspect the file.
Or Start over and manually type the commands.
I've looked into the forum for one hour now, and tried everything I've found here but still I don't manage to run my .exe using a powershell script.
Please forgive my ignorance, I'm very new with powershell..
Basically, my script is aimed to daily monitor files loaded.
For this, I need to list .txt files in my working directory, which I managed to do.
My issue is that when files arrive in my working folder, they have nonspeaking names that I can't figure out which business it's related to.
There is a RemaneFile1.exe executable that renames files according to some data codes inside my .txt files from something like "Inf320638.txt" to something like "lot_RUHPEG_296_320638" and that is exactly what .exe I would like to run using powershell (I didn't coded it, and I don't know how it works, just that when I manually run it it renames my files just fine).
I've tried those two command lines below, but when I look at my files, they are actually not renamed.
1. &".\INFOCENTRE\LOTS\RenameFile1.exe
=> When I check my file name it's still like "Inf320638.txt".
2. Start-Process ".\INFOCENTRE\LOTS\RenameFile1.exe" => A command prompt shows up for an instant, but when I check my file name it's like "Inf320638.txt".
Any help would be highly appreciated,
Brgs,
Thomas.
Try to run the executable with the following arguments:
Start-Process .\INFOCENTRE\LOTS\RenameFile1.exe -WorkingDirectory .\INFOCENTRE\LOTS -Wait
It might be, that the workingdirectory is what screws it up. The -wait switch lets powershell wait for the programm to finish, you could omit it.
I've got a bat script that does a few cmds and also runs a stack of powershell scripts. Sometimes it errors out on the second or third command because it's cutting off a few characters. It's also done this on xcopy commands following a powershell script and vice versa. So here is an example:
Bat file:
xcopy "\\server\####\####\######" "C:\######" /S/I/E/Y
powershell "C:\SetupVM.ps1"
output:
\\server\Hard Disks\******.vhdx
\\server\Virtual Machines\*******.XML
2 File(s) copied
C:\Users\*****>rshell "C:\SetupVM.ps1"
'rshell' is not recognized as an internal or external command,
operable program or batch file.
Has anyone seen this before? Any ideas on how to avoid it?
Try opening your batch file in Notepad, and then 'Save As...' and be sure to select the ANSI encoding. Then don't touch it in your other editor :D.
It seems related to this issue.
I ran into this trying to write a batch file in Atom, and I think it was automatically encoding it to UTF-8. Opening in Notepad and re-saving it using ANSI encoding solved it for me.
A complicating issue for me was that my script was switching back and forth between git branches during my batch file, and if the batch file was different between the branches it would start to execute only partial lines as the computer would try to pick up the next piece of the batch, and it was causing the same issue.
From what I can see, the command line does not recognize the 'rshell' command.
Check your enviroment variables or start the command from where 'rshell'.com/.exe is located.
Other than this there is not much to say without seeing the content of the powershell script...