×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Fix My VBScript

Fix My VBScript

Fix My VBScript

(OP)
I have this vbscript that I copied from an online source. It starts the Spotify application on my desktop and begins playing the specified playlist. I can double-click the vbs file from Windows Explorer and it works just fine. I created a scheduled task to run the script. When I attempt to run the scheduled task a Windows dialog appears asking How do you want to open this file?

Here's the vbscript code with my comments added:

Set WshShell = WScript.CreateObject("WScript.Shell")
'This is the path to the Windows Spotify application. (I realize that they've misspelled CommandLine, but it works spelled this way for some reason)
Comandline = "C:\Users\Tod\AppData\Local\Microsoft\WindowsApps\Spotify.exe"
WScript.sleep 500
'The argument to the Run method is the playlist within the Spotify application to run
CreateObject("WScript.Shell").Run("spotify:user:todtown:playlist:4zFrHtT8bSgXIltkkiScMk")
WScript.sleep 3000
WshShell.SendKeys " "

My scheduled task simply says:
"C:\Users\Tod\Load Spotify.vbs"
With no arguments

Can anyone suggest changes to either the script or the scheduled task, or other suggestions that I can try?

tod

RE: Fix My VBScript

>I realize that they've misspelled CommandLine, but it works spelled this way for some reason

Because the script does not then subsequently use this, and because ComandLine here is just a variable name, it could have been anything, so a spelling error is not necessarily an issue anyway.

>Can anyone suggest changes to either the script or the scheduled task

Unfortunately cannot replicate your problem, my version of the script works fine from the task scheduler (on Windows 10)

CODE

Set WshShell = WScript.CreateObject("WScript.Shell")
'The argument to the Run method is the playlist within the Spotify application to run
CreateObject("WScript.Shell").Run("spotify:user:todtown:playlist:4zFrHtT8bSgXIltkkiScMk")
WScript.sleep 3000 'On slower systems you may need to increase this delay, as it allows Spotify to open properly
WshShell.SendKeys " " 

RE: Fix My VBScript

(OP)
Thanks strongm for the reply. I was suspicious of those first two line of my script. Didn't seem like they were being used for anything. I solved the problem by modifying my scheduled task. Now the task opens wscript.exe and the argument is the path to the vbscript file. That worked perfectly.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close