VBScript
Posted by Darren | Posted in Programming | Posted on 10-08-2007
Tags: code, Programming, source
0
I’ve never played around much with VBScript, but it’s pretty neat. Rusty was showing me some code he did after reading this TechEBlog article. We thought it would be funny to write a script that unmuted, maxed the volume, and played a sound file. Here is the VBScript I came up with (save as .vbs):
set oshell=createobject(“wscript.shell”)
oshell.run “sndvol32″
oshell.appactivate “volume control”
WScript.sleep 600
oshell.appactivate “volume control”
oshell.sendkeys “{tab}”
wscript.sleep 600
For X = 1 To 500
oshell.sendkeys “^{UP}”
oshell.appactivate “volume control”
Next
wscript.sleep 600
oshell.sendkeys “m”
wscript.sleep 600
oshell.sendkeys Chr(32)
wscript.sleep 600
oshell.appactivate “volume control”
wscript.sleep 600
oshell.sendkeys “%{f4}”strSoundFile = “C:\WINDOWS\Media\notify.wav”
Set objShell = CreateObject(“Wscript.Shell”)
strCommand = “sndrec32 /play /close ” & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, False
Wscript.Sleep 1000
Continue = MsgBox (“Message Box Message”, vbYesNo, “Message Box Title”)
Here is the batch file to copy files to computer (save as .bat):
@echo off
xcopy /Y “sound.vbs” “c:\temp\”
xcopy /Y “sound.ico” “c:\temp\”
xcopy /Y “sound.lnk” “%USERPROFILE%\Desktop”
