Mapping a network drive without hardcoding a drive letter in a batch file

If you don’t have multiple network shares connected simultaniously, you can make net use * assign a free drive letter for you. Afterwards you can use robocopy to access the share via its UNC path and release any connected share with net use * /delete. Something like this: @echo off net use * \\192.168.0.1\Share\wwwroot\MyProject /user:mydomain\myuser … Read more

How can I move all the files from one folder to another using the command line?

You can use move for this. The documentation from help move states: Moves files and renames files and directories. To move one or more files: MOVE [/Y | /-Y] [drive:][path]filename1[,…] destination To rename a directory: MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2 [drive:][path]filename1 Specifies the location and name of the file or files you want to … Read more

Batch File To Play A Song

Here is a Bat/VBS to play an audio file : @echo off set file=track12.mp3 ( echo Set Sound = CreateObject(“WMPlayer.OCX.7″^) echo Sound.URL = “%file%” echo Sound.Controls.play echo do while Sound.currentmedia.duration = 0 echo wscript.sleep 100 echo loop echo wscript.sleep (int(Sound.currentmedia.duration^)+1^)*1000) >sound.vbs start /min sound.vbs

Is there a short cut for desktop folder in Windows batch?

You can use “%USERPROFILE%\Desktop” but I don’t know from which version of Windows it is built in. If your want the real folder where Desktop is located then use this code in the bach for /F “skip=2 tokens=3* delims= ” %%a in (‘reg query “HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders” /v Desktop’) do set DesktopFolder=”%%a” This requires the … Read more