Quotes not working in script [closed] - vbscript

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 7 years ago.
Improve this question
I am trying to run the below command in a script I am making but due to the spaces the script just will not run as it does not like the syntax..can someone help me on the syntax? I have tried various combinations of double quotes, single quotes and more but it just does not like it:
If Not oLib.RunCommand( "REG ADD ""`HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3`"" /V ""`1806`"" /T ""`REG_DWORD`"" /D ""`00000000`"" /F", True, Array(0, 3010)) Then
It just does not amend the registry key though..

Try
If Not oLib.RunCommand("REG ADD ""HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3"" /V ""1806"" /T ""REG_DWORD"" /D ""00000000"" /F", True, Array(0, 3010)) Then
OR
If Not oLib.RunCommand("REG ADD 'HKLM\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3' /V '1806' /T 'REG_DWORD' /D '00000000' /F", True, Array(0, 3010)) Then
If this doesn't work let us know exactly what oLib is and what you are trying to do,

Related

Command Prompt Help, using dir to list files that start with one letter [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 months ago.
Improve this question
I'm currently in a coding class and have run into a roadblock, I'm pretty sure it's super simple but I just can't find on any forum or other online help. I'm working with Command Prompt on Windows and need to use the DIR command but specifically to only list the files that start with a letter. What would the command for this look like?
As far as I know cmd does not support 'letter' wildcard. But, you can use findstr command to filter unnecessary items using regex-like syntax:
dir /a-d /b | findstr /I "^[A-Z].*"
Please type dir /? and findstr /? to see all options.
In PowerShell you can use:
dir "[A-Z]*" -File

Problem with Space in Variable on Batch-Script [closed]

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
I have a problem with my batch script.
I want to delete a file witch I first copy in an variable.
If I output the variable all spaces are there.
but if I try to delete it, the filename stops at the first space.
For /F "delims=" %%i in ('dir /B *.mkv') do set orginaldatei=%%~ni.mkv
ECHO %orginaldatei%
del %orginaldatei%
I also tried it without the "delims=".
The solution is to quote the filename.
del "%orginaldatei%"
That's because del accepts a list of files to delete, delimited by spaces.
Quotes help to make clear, if a space is a delimiter or part of a filename.
del my file --- Tries to delete "my" and "file"
del "my file" --- Tries to delete "my file"

Remove files in given folder but leave files in subfolders [closed]

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 5 years ago.
Improve this question
I think this should be rather simple but I want to delete all the files that are stated in for example: C:\TEST but I want to leave the files that are located in subdirectories of this folder. For example files in the folder: C:\TEST\Backup should not be deleted.
When using the following batch command all the files get deleted including those located in sub directories but it leaves the folder:
DEL /S C:\TEST\ /q
Does anyone know the command that I need?
It is as simple as this:
from cmdline:
for %a IN (C:\TEST\*.*) do echo "%a"
OR In a batch script, just add an additional %
for %%a IN (C:\TEST\*.*) do echo "%%a"
Just replace echo with del once you are confident with your final script.
OR simply doing:
del C:\TEST /q
All these things can be found by simply opening cmd.exe and running ANY of the commands with the /? switch. For instance.
for /?
del /?
etc.

How do you find the last modified folder in a directory with command prompt? [closed]

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
In the end, I want to copy the last modified folder in a directory. In order to do this, I need to pass in the name of the last modified folder to xcopy.
How do you find the last modified folder, not file, in a directory with command prompt? I have found many scripts that will find the last modified file, but I cannot seem to find a command that will find the last modified folder.
Any help would be appreciated.
#echo off
for /f "delims=" %%a in (' dir /ad /od /b ') do set "folder=%%a"

how to access server using cmd( \\Server\Volume\File) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I need to get folder names in my server, as you know when you start cmd.exe it has default path name like "C:\Documents and ....". I can get folder names which are in my "C:/" by typing dir *.* /b /o:n > index.txt.
so I have this;
C:\Documents and Settings\Name>dir *.* /b /o:n > index.txt
I need this if there is a way;
\\Server\Volume\File>dir *.* /b /o:n > index.txt
sorry for my broken english, any help wellcome.
Use:
pushd \\Server\Volume
dir
popd
You could map the drive and then browse that directory:
net use Z: \\Server\Volume
cd /d Z:\
dir
Hope this helps :)

Resources