137 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
Evan Nadeau's user avatar
  • 1,511
37 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 ...
I say Reinstate Monica's user avatar
28 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 ...
Syberdoor's user avatar
  • 1,832
12 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:\...
N Khan's user avatar
  • 221
10 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 ...
dbenham's user avatar
  • 11.4k
9 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 ...
Ramhound's user avatar
  • 42.7k
8 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 /? ...
JosefZ's user avatar
  • 13.2k
6 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....
Ben N's user avatar
  • 41k
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 ...
RinkyPinku's user avatar
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....
dbenham's user avatar
  • 11.4k
6 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....
CubicleSoft's user avatar
5 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 ...
Vodalus's user avatar
  • 51
5 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
w32sh's user avatar
  • 11.9k
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 ...
LotPings's user avatar
  • 7,241
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 ...
Dranon's user avatar
  • 262
5 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" ...
Hackoo's user avatar
  • 1,404
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 ...
Hackoo's user avatar
  • 1,404
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 ...
Transcendental's user avatar
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 ...
headkase's user avatar
  • 1,910
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 ...
thiyagu selvaraj's user avatar
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 ...
clhy's user avatar
  • 6,382
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. ...
Ben N's user avatar
  • 41k
4 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 = ...
SDsolar's user avatar
  • 1,616
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 ...
Ron Rosenfeld's user avatar
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 ...
mael''s user avatar
  • 1,946
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 ---&...
phuclv's user avatar
  • 27.8k
4 votes
Accepted

How to tell what program is using Windows Based Script Host?

wscript.exe is also known as Windows Script Host, a service that provides the Windows system with scripting abilities ,generally VBscript and JScript. In Powershell, you can run this to see all ...
Wasif's user avatar
  • 8,504
4 votes

What are the .wsf , .wsh, and .wsc files?

A .wsh file is a "Windows Script Host control file": Text document that contains properties and parameters for a certain script, i.e. a .VB or .VBS file; used for customizing the execution ...
Reddy Lutonadio's user avatar
4 votes
Accepted

Detect changed files

The .NET framework has System.IO.FileSystemWatcher, which can be accessed from PowerShell (example).
u1686_grawity's user avatar
3 votes

Windows Command line get disk space in GB

If you just need to check if the drive have enough free space (to install or copy something for example) you can try wmic query like this: wmic LogicalDisk where "DeviceID='c:' and FreeSpace > ...
anilech's user avatar
  • 130

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