Search found 76 matches

by Eureka!
17 Mar 2020 08:01
Forum: DOS Batch Forum
Topic: close all open folders in file explorer
Replies: 1
Views: 249

Re: close all open folders in file explorer

What have you tried yourself? And where did that go wrong? If you have Launch folder windows in a separate process enabled: taskkill.exe /im explorer.exe If you have that setting disbaled : taskkill.exe /im explorer.exe /F & explorer.exe The second command could also be used in the first case, but t...
by Eureka!
16 Mar 2020 04:50
Forum: DOS Batch Forum
Topic: Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies
Replies: 2
Views: 245

Re: Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies

Did you call your script WMIC.cmd/.bat?
That would explain this behaviour exactly.

I make a habit out of adding the file extension to programs used in scripts to avoid this (replace WMIC with WMIC.exe)

But it is always better to avoid naming your scripts the same as an already existing program.
by Eureka!
13 Mar 2020 05:43
Forum: DOS Batch Forum
Topic: Run ALL .reg, .ps1, and .bat files in a folder.
Replies: 5
Views: 421

Re: Run ALL .reg, .ps1, and .bat files in a folder.

Something like this should take care of that:

Code: Select all

For %%i In ("%Folder%\*.reg") Do (
   echo Processing %%i
   regedit /s "%%i"
)
by Eureka!
12 Mar 2020 10:57
Forum: DOS Batch Forum
Topic: Run ALL .reg, .ps1, and .bat files in a folder.
Replies: 5
Views: 421

Re: Run ALL .reg, .ps1, and .bat files in a folder.

If one or more of your 80 filenames contains spaces, things will go wrong. Same goes for your %Folder%: if it contains one or more spaces, things go wrong. For example, in your .reg routine, replace For %%i In (%Folder%\*.reg) Do (regedit /s %%i) with: For %%i In ("%Folder%\*.reg") Do (regedit /s "%...
by Eureka!
09 Mar 2020 14:42
Forum: DOS Batch Forum
Topic: Tiemout in a for loop
Replies: 2
Views: 716

Re: Tiemout in a for loop

In your original code, there are some commands that will prevent a correct functioning. Note: just for a learning purpose; I would go with @aGerman's code. set enabledelayedexpansion should be: setlocal enabledelayedexpansion (setlocal /? or details) call calculate.exe -f %file_req% should be: call ...
by Eureka!
23 Feb 2020 13:04
Forum: DOS Batch Forum
Topic: execute simple cmd line hidden without file
Replies: 12
Views: 2688

Re: execute simple cmd line hidden without file

Nice! But sadly it has the same issue as my code above. It wasn't intended to be a solution; just sharing some tips. @einstein1969 already found a fitting solution, but I would keep it simple: - Create a shorctut to cmd /c ... - and configure this shortcut to run minimized. - In this mysterious sof...
by Eureka!
22 Feb 2020 09:57
Forum: DOS Batch Forum
Topic: execute simple cmd line hidden without file
Replies: 12
Views: 2688

Re: execute simple cmd line hidden without file

You could list all functions of a .COM object by using "$wshShell | Get-Member;" (within powershell): Thank you for this! Very useful! BTW, another way to start a process hidden from PowerShell: Start-Process -filepath "cmd.exe" -argumentlist "/c pause" -WindowStyle Hidden (Don't know in which vers...
by Eureka!
13 Feb 2020 16:16
Forum: DOS Batch Forum
Topic: Get time running from the Browser
Replies: 3
Views: 2776

Re: Get time running from the Browser

Try it with wmic process where caption='notepad.exe' get creationdate /value Result is the starttime of notepad.exe: CreationDate=20200213231040.876129+060 You will have to do your own arithmetic to get the running time from that :) (there are several threads on this forum that can help you with that)
by Eureka!
11 Feb 2020 12:42
Forum: DOS Batch Forum
Topic: Multi-line commands with leading spaces
Replies: 7
Views: 2779

Re: Multi-line commands with leading spaces

Thanks @jeb and @penpen; makes sense now.

(except for the "obvious" :shock: <nul method; will have to chew on that for a while ....)
by Eureka!
11 Feb 2020 11:07
Forum: DOS Batch Forum
Topic: Multi-line commands with leading spaces
Replies: 7
Views: 2779

Re: Multi-line commands with leading spaces

penpen wrote:
11 Feb 2020 07:42
You don't execute the echo-command but a single space!
You are right (that is what the error message says, after all), but I am obviously missing some in-between steps to make this a logical explanation.
If it is not too much effort/trouble, could you give some more details?
by Eureka!
10 Feb 2020 16:38
Forum: DOS Batch Forum
Topic: How to create a For loop to execute lines in the same .bat file
Replies: 6
Views: 2492

Re: How to create a For loop to execute lines in the same .bat file

Ah, now I see .. you used double double-quotes! That will result in too many quotes here: REG Delete ""HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs" /V "C:\\Windows\\system32\\SCHelp.dll"" /F I would keep it simple: Keep the exceptions out of the FOR-loop, like this: for %%k in ( "HKLM\...
by Eureka!
10 Feb 2020 16:16
Forum: DOS Batch Forum
Topic: How to create a For loop to execute lines in the same .bat file
Replies: 6
Views: 2492

Re: How to create a For loop to execute lines in the same .bat file

for %%k in ( "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs" /V "C:\\Windows\\system32\\SCHelp.dll" ) DO Echo REG Delete "%%~k" /F It deletes all values and "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs" That is expected when you do it like this: Between teh () are a list o...
by Eureka!
10 Feb 2020 02:03
Forum: DOS Batch Forum
Topic: How to create a For loop to execute lines in the same .bat file
Replies: 6
Views: 2492

Re: How to create a For loop to execute lines in the same .bat file

Like your subject - "How to create a For loop to execute lines in the same .bat file" - already says: Use a FOR loop. Type FOR /? for (a lot) more information. An example: for %%k in ( "HKLM\SOFTWARE\Rainmaker Research" "HKCR\.1sc" "HKCR\.2sc" "HKCR\.3sc" "HKCR\.4sc" "HKCR\.5sc" ) DO echo REG Delete...
by Eureka!
10 Feb 2020 01:51
Forum: DOS Batch Forum
Topic: Multi-line commands with leading spaces
Replies: 7
Views: 2779

Re: Multi-line commands with leading spaces

Thank you for clearing that up!

(After posting I realized that would make no difference what the answer would be (all in the past), but it was one of those things that kept nagging me ... Thanks for saving me :))
by Eureka!
09 Feb 2020 17:02
Forum: DOS Batch Forum
Topic: Multi-line commands with leading spaces
Replies: 7
Views: 2779

Multi-line commands with leading spaces

These scriptlines: for %%x in (*.txt) do ^ echo %%x produces an error: ' ' is not recognized as an internal or external command, operable program or batch file. Removing the spaces before echo leads to the expected results. The question: Was it always like this? I am not entirely sure but I think I ...