Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Guimenez

vbs script to change documents paths do another location

Recommended Posts

The vbs script is still not working, if i remove the bracket Act.RegWrite A2(0),Dir

but if i use the hta version it works :D

is it possible to customize the application?

it's more simple to have butons to choose the destination drive (button to drive D:),button to drive E:) or simple just inserting the drive letter without the " : "

and after successfully operation the program will automatically exit

what are the steps for doing this please

once again thanks all of you for the help

Guimenez

Share this post


Link to post
Share on other sites

@VideoRipper

Well, if it wasn't clear enough, I was kidding, obviously nothing personal, the bashing was not actually against anyone, but rather a simple attempt to remember people the principles of Occam's Razor:

http://en.wikipedia.org/wiki/Occam's_razor

or, if you prefer, KISS approach (Keep It Simple Stupid).

The point is general.

Lots of people think that since they have Delphi (and think they can program in it - mind you I am not saying that the "think" applies to you personally :whistle:) they are the allmighty (and only) Gods of computing.

Script-kiddies, as you like to call the small number of people actually using ALREADY AVAILABLE on the given platform scripting engines to simply solve simple problems, on the other hand, like to think that Albert Einstein was, besides a great physicist, a very wise man:

Make everything as simple as possible, but not simpler.
Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction.

So, only, a "philosophical" matter. :)

The whole idea of "compiling" is, in my perverted mind ;), a completely "wrong" approach, a quick (and at the time needed) workaround to improve the efficiency of SLOW processors/LOW computer power, useful if you really have COMPLEX needs, you trade in flexibility and freedom for speed, which is of course very good for Software companies but has no reason to be if speed is irrelevant and if you are going to share the source anyway.

A "simple" example of a "simple" conversion from .exe to batch:

http://www.forensicfocus.com/index.php?name=Forums&file=viewtopic&t=4805

(the original .exe is 1,163,264 bytes)

The batch is (in the published form) 1,024 bytes. (in a bit more readable version it is 1,278 bytes).

Since it's use is targeted to "assemble" snippets, like a bootsector or a file header, I personally see the advantages of the "simple" approach, and probably Yzöwl :thumbup could make it simpler/better yet.

jaclaz

Share this post


Link to post
Share on other sites
Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction.

Ah well... I guess I'm just that intelligent fool and not a genius :lol:

Greetz,

Peter.

Share this post


Link to post
Share on other sites

Here I change the HTA and added a Listbox that collects all local hard drives

Save As ProLocChange_V1.hta


<TITLE>Change Music, Personal, Pictures, Video </TITLE>
<HTA:APPLICATION
Id="ChangeLoc"
APPLICATIONNAME="LocChange"
SCROLL="no"
SINGLEINSTANCE="yes"
SELECTION="NO"
CONTEXTMENU = "NO"
BORDER="Thin"
BORDERStyle = "Normal"
INNERBORDER = "YES"
MAXIMIZEBUTTON = "NO"
MINIMIZEBUTTON = "NO"
SYSMENU = "NO">
<STYLE Type='text/css'>
Body
{
Font-Size:10.25pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Lucida Console, Arial, Tahoma, Comic Sans MS;
Color:Black;
BackGround-Color:Transparent;
Filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='#ece6e0',EndColorStr='#c0bab4');
Margin-Top:1;
Margin-Bottom:1;
Margin-Left:4;
Margin-Right:4;
Padding-Top:1;
Padding-Bottom:1;
Padding-Left:4;
Padding-Right:4;
Text-Align:Center;
Vertical-Align:Top;
Border-Top:0px Transparent;
Border-Bottom:0px Transparent;
Border-Left:0px Transparent;
Border-Right:0px Transparent;
}
.Txt
{
Font-Size:8.25pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Lucida Console, Arial, Tahoma, Comic Sans MS;
Margin-Left:1;
Margin-Right:1;
}
BUTTON
{
Width:71pt;
Height:14pt;
Cursor:Hand;
Font-Size:8.25pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Lucida Console, Arial, Tahoma, Comic Sans MS;
Color:#001137;
Text-Align:Center;
Vertical-Align:Middle;
Filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='AliceBlue',endColorStr='LightSlateGray');
Border-Top:0px Transparent;
Border-Bottom:0px Transparent;
Border-Left:0px Transparent;
Border-Right:0px Transparent;
Padding-Top:0;
Padding-Bottom:2;
Padding-Left:0;
Padding-Right:0;
Margin-Top:1;
Margin-Bottom:1;
Margin-Left:1;
Margin-Right:1;
BackGround-Color:Transparent;
}
.B1
{
Color:#003711;
Filter:progid:DXImageTransform.Microsoft.Gradient
(StartColorStr='#BAEABA',endColorStr='#226644');
}
Select.Bx1
{
Font-Size:8.05pt;
Font-Weight:Bold;
Font-Family:Segoe Ui, Lucida Console, Arial, Tahoma, Comic Sans MS;
}
</STYLE>
<script LANGUAGE='JScript'>
window.resizeTo (375,151)
window.moveTo(screen.availWidth / 2 - (425/2),screen.availHeight / 2 - (201/2));
var Act = new ActiveXObject("Wscript.Shell");
var Fso = new ActiveXObject("Scripting.FileSystemObject");
</SCRIPT>
<script language="VBScript">
'-> Array To Hold The Reg Keys And Users Folders
Dim Loc :Loc = Array( _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal - os meus documentos", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Pictures - os meus documentos\As minhas imagens", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music - os meus documentos\A minha m`sica", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Video - os meus documentos\Os meus vÌdeos")
Dim A1, C1, Dir, Obj
'-> Populate The Listbox With Drives
Function Window_onLoad()
For Each Obj In Fso.Drives
If Obj.DriveType = 2 Then
C1 = C1 + 1
Set Lst = Document.createElement("OPTION")
Lst.Text = Obj & "\"
Lst.Value = Obj & "\"
If C1 Mod 2 Then
Lst.style.backgroundcolor = "#D9D9D9"
Lst.style.color = "#3A3A3A"
Else
Lst.style.backgroundcolor = "#E9E9E9"
Lst.style.color = "#235779"
End If
Drv.Add(Lst)
End If
Next
End Function
'-> Work
Function Work(Drv)
If Drv = "" Then
alert("Please Input A Drive Letter" & vbcrlf & "Error Number 1")
Else
For Each Obj In Loc
A1 = Split(Obj," - ")
Dir = Drv & A1(1)
If Not Fso.FolderExists(Dir) Then Fso.CreateFolder(Dir)
Act.RegWrite A1(0),Dir
Next
End If
End Function
</SCRIPT>
<BODY Scroll='No'>
<TABLE Style='Margin-Top:3;Margin-Bottom:5;'>Change Music, Personal, Pictures, Video</TABLE>
<TABLE><TD Class='Txt' Style='Width:161pt;'>
Select The Drive That You Want To Use For The New User Profile Location</TD>
<TD><Select size='1' Name='Drv' Class='Bx1' Style='width:45pt;' tabindex=1></Select></TD>
</TABLE>
<TABLE Style='Margin-Top:3;'><TD>
<BUTTON ID='Btn01' OnMouseOver="this.className='B1'" OnMouseOut="this.className=''" OnClick='Work(Drv.value)'>Change</BUTTON>
</TD><TD>
<BUTTON ID='Btn02' OnMouseOver="this.className='B1'" OnMouseOut="this.className=''" OnClick='window.close();'>Close</BUTTON>
</TD></TABLE>

Edited by gunsmokingman
Change to Codebox from just Code

Share this post


Link to post
Share on other sites

I think I'd prefer to see it fill the list box with just fixed and network drives!

objWMIService.ExecQuery("Select * from " _		 & "Win32_LogicalDisk Where DriveType = '2' OR Drivetype = '3'")

Share this post


Link to post
Share on other sites

Isn't this all getting a bit too complicated now?

(Yeah it's me, the smart-arse again...) :hello:

As I understand the original post, Guimenez was just looking for a simple script

that could move his "My Documents"-folder.

After debating whether scripting or programming is best and having had a solution

with all kinds of selection-dialogs, wouldn't it be much easier to let Windows do

all the "Hard work" (because the function is already built in)? :unsure:

The image below is from Windows XP, but I understand this feature is available from

Windows 2k upwards...

movemydocs.png

(Just right-click on "My Documents" and select another target)

Peace, :angel

Peter.

Share this post


Link to post
Share on other sites
The image below is from Windows XP, but I understand this feature is available from

Windows 2k upwards...

Windows 7 seems to be missing that feature.

DocProperties.png

Share this post


Link to post
Share on other sites

Thanks gunsmokingman and all of you that are help me in this script.

This script is working fantastic :D:D:D

is it possible to show a box saying that the job was successfully done and then after pressing ok

the script will close?

many many thanks :D

PS: i notice that we need to change the User Shell Folders too, i change the array, adding the User Shell Folders location too

Edited by Guimenez

Share this post


Link to post
Share on other sites

Actually I was under the impression that there should be no need to touch the 'Shell Folders' keys.

All work should be done on the 'User Shell Folders' keys which should in turn propagate down to the Shell Folders key.

Share this post


Link to post
Share on other sites

Actually I was under the impression that there should be no need to touch the 'Shell Folders' keys.

All work should be done on the 'User Shell Folders' keys which should in turn propagate down to the Shell Folders key.

i'm searching changes on the registry and i've found that in Windows XP some folders (like video and music) are not in

the "User Shell Folders" but in the "Shell Folders". I'm changing the two occurrences in the registry :D

Guimenez

Share this post


Link to post
Share on other sites

I've found how to show a box after the finished operation and then exit the program :D:D

add this lines after the next code:

alert("Changes successfully done")

onclick=window.close()


For Each Obj In Loc
A1 = Split(Obj," - ")
Dir = Drv & A1(1)
If Not Fso.FolderExists(Dir) Then Fso.CreateFolder(Dir)
Act.RegWrite A1(0),Dir
Next

like this:


For Each Obj In Loc
A1 = Split(Obj," - ")
Dir = Drv & A1(1)
If Not Fso.FolderExists(Dir) Then Fso.CreateFolder(Dir)
Act.RegWrite A1(0),Dir
Next
alert("Changes successfully done")
onclick=window.close()

many thanks all of your for such a great help :D

this application will help a lot of people that needs to change the personal folders after installing windows

Guimenez

Share this post


Link to post
Share on other sites

Please gunsmokingman

can an you convert this to vbs?

because i need to run with a batch file and the batch files doesn't runs HTA files :(

many thanks

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...