Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to make a .bat file that when opened will copy a folder and all it contains into another folder on another partition. Here is exactly what I am trying to do:
Copy C:\Documents and Settings\user\Desktop\Документи and all it contains to D:\Backup. I have tried with many xcopy commands but without result. Thanks.
I launched the command prompt with /k and saw this
which made me think there is a problem with the font. I installed new font that should fix this (YGP_NT) but I am having the same problem (yes, I changed it from the cmd Properties, edited the TrueTypeFont with regedit and restarted the PC). I can write in cyrillic in the cmd if that can help.
xcopy "%userprofile%\Desktop\Документи" "D:\Backup\" /s/h/e/k/f/c
should work, assuming that your language setting allows Cyrillic (or you use Unicode fonts in the console).
For reference about the arguments: http://ss64.com/nt/xcopy.html
xcopy e:\source_folder f:\destination_folder /e /i /h
The /h is just in case there are hidden files. The /i creates a destination folder if there are muliple source files.
xcopy "C:\Documents and Settings\user\Desktop\Документи" "D:\Backup" /s /e /y /i
Probably the problem is the space.Try with quotes.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
How do I modify the following batch script to kill a process instead of a task?
For example, if BBB.exe once executed runs as a process, how would I kill that process once AAA.exe is closed?
To clarify, if you open task manager, tasks are listed under the "applications" tab and a process is listed under the "processes" tab. The program represented as "BBB.exe" that I'm trying to kill immediately once AAA.exe is closed only opens to the system tray and not the task bar and therefore is not present in the "applications" tab but only the "processes" tab when open. The following batch file does not have any effect on ending program "BBB.exe" even when the machine is ran with admin privileges. I've seen the "Process.Kill()" command but I'm not sure how to properly utilize it.
Thanks in advance.
#Echo off
CD "C:\Users\XXX\XXX\XXX"
start AAA.exe
CD "C:\XXX\XXX"
start BBB.exe
:TEST
Tasklist /FI "IMAGENAME eq AAA.exe" 2>NUL | Find /I /N AAA.exe>NUL
If "%ERRORLEVEL%"=="0" goto ACTIVE
:DEAD
Taskkill /F /IM BBB.exe
Exit
:ACTIVE
Timeout /T 1
Goto TEST
I found out what the problem is.
The issue lies in that the "taskkill" command was never being deployed because command prompt remained in the directory of BBB.exe where the "taskkill" executable doesn't exist.
Simply changing the directoy to either "system32" or "syswow64" (depending on the OS installation) after executing both programs and before running the "taskkill" command in the batch file solved the issue.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I am trying to create XML files for each of the wireless networks on my computer, containing their passwords, in a general solution (without knowing the exact names of each network) as shown here: Netsh WLAN Commands for Windows 10 – Here’s a Full Tutorial! in the "Export and Import Wireless Profile" section.
Using the command they suggest (which I've seen in other places as well)
netsh wlan export profile folder=c:\ key=clear
I receive the following error:
The filename, directory name, or volume label syntax is incorrect.
I have tried saving it to another folder, both in the C and D drives and neither have worked. If I add "name=profileName" with the name of an existing profile it creates an XML file for that specific profile, but I want to create XML files for each network considering I won't know their names.
Is there another way I can to that, or something I can do to fix what's causing this problem? Thank you in advance to any helpers, I appreciate your time!
The cmd is already in administrator mode
In order to get the names of your individual profiles, you can run the command NetSh WLAN Show Profiles. If you do that within a for-loop, you can extract the profile names and inject those into the NetSh WLAN Export Profile Name="<ProfileName>" Key=clear Folder=C:\ command.
In cmd, (i.e. the Command Prompt 'Run as administrator'), the following command line may do that for you:
For /F "Tokens=1,* Delims=:" %G In ('%__AppDir__%netsh.exe WLAN Show Profiles 2^> NUL ^| %__AppDir__%findstr.exe /RC:" : [^ ]"') Do #For /F "Tokens=*" %I In ("%H") Do #%__AppDir__%netsh.exe WLAN Export Profile Name="%I" Key=clear Folder=C:\
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I can use the variable %CD% to run a command-line virus scanner to scan the current directory from command prompt like this.
C:\AVPTool\AVPTool.exe SCAN %CD% /R:KAVSCANLOG.txt
I'd like use it from context menu to easily scan the folder with just two clicks.
I modified the registry and created a key called Scan with AVPTool in HKEY_CLASSES_ROOT\Directory\shell and within that key I created another key called command and changed the value to
"cmd.exe /k cd %1 & C:\AVPTool\AVPTool.exe SCAN %CD% /R:KAVSCANLOG.txt"
But this doesn't work since %CD% doesn't get translated into the current working directory.
I'd try
"cmd.exe /k cd %1 & C:\AVPTool\AVPTool.exe SCAN "%1" /R:KAVSCANLOG.txt"
since the line would be processed by replacing the %-variables and THEN executed, %CD% would be replaced by whatever the current directory of the INVOKING process is, not the directory in which the process is RUN. The current directory is only changed AFTER the cd has been executed, and by that time, %CD% has already been installed into the command - as it stood when the cmd.exe was invoked.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How can I make my commands run in NppExec run in cmd, as opposed to the built in console, which doesn't work with things like: "Press any key to continue", which only works when you press enter?
You want to take a look at cmd /? output and http://ss64.com/nt/. Using start along with cmd /c will give an external window and using cmd /k will keep it in the nppexec console. One thing I don't like about the /k option is that it really isn't true as 'any key' doesn't do the trick and Enter needs to be used.
Test it out with cmd /k pause and start cmd /c pause.
Notice the start option has the window close, so any history will go away too. If that's important then substitute /k for the /c and use exit when done.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
During my NSIS setup script for a WinForms app, I use the following CACLS command to give the Users group full rights to a subfolder:
Exec 'CACLS "$INSTDIR\SubFolder" /E /T /C /G "Users":F'
So in effect the CACLS command executed is something like:
CACLS "c:\Program Files\MyApp\SubFolder" /E /T /C /G "Users":F
When I then look at the Folder permissions in Windows Explorer (right click on the folder and choose Properties, go to the Security tab), the correct permissions are there but they are uneditable.
Furthermore, clicking the Advanced button for the 'Advanced Security Settings' shows that SubFolder is inheriting the "Users" group permissions from a 'Parent Object', but what is that Parent Object, because its not the folder above.
Why are the permissions added by CACLS uneditable, and why are they inherited from nonexistent parent object? I thinking I may have set the options on CACLS wrong.
I'm on Windows XP.
I think I figured it out: Changing CACLS to use /P 'replace' rather than /G 'grant' seemed to work better:
CACLS "c:\Program Files\MyApp\SubFolder" /E /T /C /P "Users":F
The options that got created were then editable in the Windows Explorer 'security' tab.
NSIS has a plugin to set permissions, you should probably use that (I can't remember if XP Home even has cacls)
The inherited permission for "Users" has to come from somewhere clearly, either the root of the drive or a parent of your parent folder (The advanced security dialog should have a inherited from column in the list)