{"id":69713,"date":"2005-05-27T11:41:00","date_gmt":"2005-05-27T11:41:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/05\/27\/how-can-i-change-the-copy-music-to-this-location-folder-in-windows-media-player\/"},"modified":"2005-05-27T11:41:00","modified_gmt":"2005-05-27T11:41:00","slug":"how-can-i-change-the-copy-music-to-this-location-folder-in-windows-media-player","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-change-the-copy-music-to-this-location-folder-in-windows-media-player\/","title":{"rendered":"How Can I Change the &#8220;Copy Music to This Location Folder&#8221; in Windows Media Player?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I change the <B>Copy music to this location<\/B> folder in Windows Media Player?<BR><BR>&#8212; BD<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, BD. You know, a lot of people think that the reason we Scripting Guys don\u2019t do very much work is because we\u2019re just plain lazy. Those people are right. However, what we tell our bosses is this: it\u2019s hard for us to do any work because every time we write a script we get hundreds of questions related to that script. That proved to be the case when we released our article &#8211; <A href=\"http:\/\/null\/technet\/scriptcenter\/funzone\/player.mspx\"><B>The Scripting Guys Really <\/B><B><I>Do<\/I><\/B><B> Rock<\/B><\/A> &#8211; that talked about scripting Windows Media Player. No sooner did we release the article than we were inundated with millions of questions about scripting Windows Media Player. Trust us, it\u2019s not easy for a bunch of lazy guys to answer millions of questions.<\/P>\n<P><B>Editor\u2019s Note:<\/B> \u201cMillions\u201d might be exaggerating just a little.<\/P>\n<P>But while we look into doing more articles on Windows Media Player we\u2019ll try to address a few of these million or so questions in this column. As you noted in your email, BD, you\u2019re having a problem with users automatically saving music files to your file servers; you\u2019d like to be able to set the default location for saving music files and you\u2019d like to be able to do it using a script.<\/P>\n<P>Before we go any further we should point out that in Windows Media Player 10 this option is no longer called <B>Copy music to this location<\/B>; instead, it\u2019s called <B>Rip music to this location<\/B>. You can find the default folder setting in the <B>Options<\/B> dialog box on the <B>Rip Music<\/B> tab:<\/P><IMG border=\"0\" alt=\"Windows Media Player\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/ripmusic.jpg\" width=\"350\" height=\"417\"> \n<P><BR>As you can see, on this computer new music files will be saved, by default, to the folder D:\\Music.<\/P>\n<P>So can you change the default location using a script? As a matter of fact, you can. The value for the rip music folder is actually stored in the registry; you\u2019ll find it here:<\/P><PRE class=\"codeSample\">HKEY_CURRENT_USER\\Software\\Microsoft\\MediaPlayer\\Preferences\\CDRecordPath\n<\/PRE>\n<P>And, yes, for some reason the registry value is named <B>CDRecordPath<\/B>. But the name doesn\u2019t matter; all that matters is that we can use a script to connect to this registry value and then set the default folder path to any valid folder we have access to. (Note that if you\u2019ve never changed the path, you might not see CDRecordPath in your registry until after you\u2019ve changed the value. But trust us, this will still work.)<\/P>\n<P>In fact, here\u2019s a script that changes the default folder setting to <B>C:\\Audio<\/B>:<\/P><PRE class=\"codeSample\">Const HKEY_CURRENT_USER = &amp;H80000001<\/p>\n<p>strComputer = &#8220;.&#8221;<\/p>\n<p>Set objRegistry=GetObject(&#8220;winmgmts:\\\\&#8221; &amp; _ \n    strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyPath = &#8220;SOFTWARE\\Microsoft\\MediaPlayer\\Preferences&#8221;\nstrValueName = &#8220;CDRecordPath&#8221;\nstrValue = &#8220;C:\\Audio&#8221;\nobjRegistry.SetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue\n<\/PRE>\n<P>We begin by defining a constant named HKEY_CURRENT_USER and setting the value to &amp;H80000001; we\u2019ll use this later on to indicate which portion of the registry we want to work with. We then connect to the WMI service, binding to the standard registry provider class (<B>StdRegProv<\/B>) in the <B>root\\default<\/B> namespace. We then assign values to three variables:<\/P>\n<TABLE border=\"0\" cellSpacing=\"0\" cellPadding=\"0\">\n<TBODY>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><I>strKeyPath<\/I>, which is assigned the registry path within HKEY_CURRENT_USER (<B>Software\\Microsoft\\MediaPlayer\\Preferences<\/B>).<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><I>strValueName<\/I>, which is assigned the name of the registry value we want to change (<B>CDRecordPath<\/B>).<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><I>strValue<\/I>, which is assigned the new folder location (<B>C:\\Audio<\/B>).<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<P>Next we call the <B>SetStringValue<\/B> method, passing the HKEY_CURRENT_USER constant and the preceding three parameters. That will change the value in the registry and, in turn, change the default folder location for copying (or, if you prefer, ripping) music.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I change the Copy music to this location folder in Windows Media Player?&#8212; BD Hey, BD. You know, a lot of people think that the reason we Scripting Guys don\u2019t do very much work is because we\u2019re just plain lazy. Those people are right. However, what we tell our bosses [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[123,31,26,3,5,192],"class_list":["post-69713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-multimedia","tag-operating-system","tag-registry","tag-scripting-guy","tag-vbscript","tag-windows-media-player-and-audio"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I change the Copy music to this location folder in Windows Media Player?&#8212; BD Hey, BD. You know, a lot of people think that the reason we Scripting Guys don\u2019t do very much work is because we\u2019re just plain lazy. Those people are right. However, what we tell our bosses [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=69713"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69713\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=69713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=69713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=69713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}