107 votes

Delete all files from a folder and its sub folders

Short and sweet PowerShell. Not sure what the lowest version of PS it will work with. Remove-Item c:\Tmp\* -Recurse -Force
  • 1,203
30 votes

How to Display a Msgbox directly from CMD

As suggested by @wysiwyg, on Pro/Business versions* of Windows you're looking for the Msg command. It's available in all modern versions of Windows (at least as far back as XP). To display a message ...
23 votes
Accepted

How to Display a Msgbox directly from CMD

As others have said there is no way to do this purely with cmd but although that is the title of the question, it seems to me that the part without file is more important to you and under certain ...
  • 1,712
13 votes

Windows Command line get disk space in GB

I realize you're looking as VBS right now, but PowerShell can do this very easily: $disk = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='C:'" | Select-Object Size, FreeSpace Write-Host ("{0}GB ...
12 votes
Accepted

Windows Command line get disk space in GB

Under the not a batch file - forced requirements clause, next cmd one-liner could help: for /f "tokens=1-3" %a in ('WMIC LOGICALDISK GET FreeSpace^,Name^,Size ^|FINDSTR /I /V "Name"') do @echo wsh....
  • 12.4k
10 votes

How to end VBScript on Windows 10?

Best option according to me is 1) Open Task Manager 2) Go to the processes tab 3) Right-click on Name header and click command line (to show Command line) 4) Under command line look for "C:\...
  • 201
8 votes
Accepted

How can I tell if my batch file is running?

I believe a lock file is the simplest reliable solution. The trick is to make sure your running batch process maintains an exclusive write lock on the file until it terminates. The beauty of this ...
  • 10.9k
8 votes
Accepted

How to list windows privileges for any user

You can use AccessChk in accomplish this task. Accesschk “domain\user” -a * will list all the permissions of a given domain user. You can call this program within a PowerShell script, concatenate ...
  • 40.3k
7 votes
Accepted

How to end VBScript on Windows 10?

Your script probably runs elevated so could become invisible in normal unelevated task manager. Run it elevated as well. Another approach: open an elevated command line window. Then, taskkill /? ...
  • 12.4k
6 votes
Accepted

How can I program a script that can tell the difference between x86 & x64?

Use batch script or vb script to store output of wmic os get osarchitecture and you get a string value saying 32-bit or 64-bit. Then you can use the typical conditional if-then-else to launch the ...
6 votes
Accepted

Writing ECHO output to VBS File not working

It helps to understand how cmd.exe parses batch scripts: Part 1 - Overview Part 2 - Percent expansion details I'll work through the processing of the first faulty line: echo strHomeFolder = oShell....
  • 10.9k
5 votes
Accepted

Get Current User Logged on Time (CMD Batch)

First, you can get 7th token from second line: for /f "skip=1 tokens=7" %a in ('quser') do @echo %a produces 1:45 but you may also use a * to get everything to the end of line: for /f "skip=1 tokens=5*...
  • 7,032
5 votes

How to stop every batch file opening as a process named cmd.exe as seen in task manager

Wow that's quite a lot of information, much of which just adds confusion, so I'll stick to the title question at hand... :) How to stop every batch file opening as a process named cmd.exe as seen ...
5 votes

How to list windows privileges for any user

For anybody looking for a PowerShell script, this ought to do it: gwmi Win32_UserProfile | foreach-object { $sid = New-Object System.Security.Principal.SecurityIdentifier($_.SID) $user = $sid....
  • 39.4k
5 votes

Users: Reset all users passwords using batch or powershell?

With Powershell (Adminstrator privileges required): get new password from user input as a SecureString Get-Localuser enumerates all local users and pipes them to the where clause which checks ...
  • 6,923
5 votes
Accepted

Launch a bat file without a command window as administrator?

You can use the ShellExecute method of the Windows Shell object instead, and use the runas operation. Set Shell = CreateObject("Shell.Application") Shell.ShellExecute "Start.bat", , , "runas", 0 ...
  • 262
5 votes
Accepted

How to make Windows speak the time at the top of the hour

Create a VBscript text file called saytime.vbs Dim speech, hr, sez hr=hour(time) if hr=0 then hr = 12 end if if hr>12 then hr = hr - 12 end if sez = hr & " O'clock" Set speech = ...
  • 1,570
4 votes

Delete user profile from command line Windows 7

I would like to provide a little bit more up-to-date solution for others who might be looking to solve this in Windows 10 Seeing how Microsoft prefers CIM over WMI, and that Delete() method for ...
  • 41
4 votes

Delete all files from a folder and its sub folders

Use PowerShell to Delete a Single File or Folder. Before executing the Delete command in powershell we need to make sure you are logged in to the server or PC with an account that has full access to ...
4 votes

Received a .vbs on Skype and ran it

It's obfuscated and you can be damn sure it isn't benign. Consider your computer you ran it on as "not secure" anymore. Which means that don't do any banking on it, don't order anything over the ...
  • 1,870
4 votes

Received a .vbs on Skype and ran it

If you're still worried about what might have happened to your computer, take a look at this ( lines are left as strings for security reason ). Do not try to execute this code If you don't know what ...
4 votes
Accepted

There is no script engine for file extension ".vbs"

The problem is caused by associating .vbs files with Notepad++ (or in some cases, perhaps a different program). You could be able to solve it by running Notepad++ as an administrator and removing the ...
  • 1,326
4 votes
Accepted

Set focus onto a specific window using VBScript

AppActivate method available in VBScript can do this Example to focus on Notepad is below: Dim ObjShell :Set ObjShell = CreateObject("Wscript.Shell") ObjShell.AppActivate("Notepad") You can also ...
  • 6,203
4 votes
Accepted

Is it possible to use Task Scheduler to open a VBS file without a command window?

Use wscript.exe to run the script, instead of cscript.exe
  • 11.3k
4 votes
Accepted

Create Internet Explorer page shortcut with VBS

According to the MSDN page on the TargetPath property: This property is for the shortcut's target path only. Any arguments to the shortcut must be placed in the Argument's [sic] property. ...
  • 39.4k
4 votes

How to Display a Msgbox directly from CMD

I needed something similar to this today. Since I couldn't find an external dependency solution I liked since I'm not really a fan of VBScript/Powershell, I went ahead and wrote one: https://github....
4 votes
Accepted

How can i show the change icon dialog box, with a vbscript or a command line?

Finally, i got a workaround with HTA to display and choose an icon to be changed for the default folder. <html> <HTA:APPLICATION APPLICATIONNAME="Hackoo Icon Folder Changer 2018" ...
  • 1,326
4 votes

VBA - Regex & Replace

There are a number of changes that could be made to improve your general code. But so far as the regex, to enable it to work as you want, change your pattern and replace strings Dim strPattern As ...
4 votes
Accepted

Rename substring of filename based on partial filename match in same folder

This ended up being a hot-mess for me since the -MyEncode gets put in the middle of the file name, but this is what I came up with and it works based on the information you've provided: @echo off ...
  • 1,876
4 votes
Accepted

How to run VBS code in a batch file?

Use a hybrid VBS-batch script. Put your VBS part between the <job><script> tags <!-- : Begin batch script @echo off cscript //nologo "%~f0?.wsf" %1 exit /b ----- Begin wsf script ---&...
  • 24.7k

Only top scored, non community-wiki answers of a minimum length are eligible