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

I am not at all an expert in vbs, what I was suggesting, maybe improperly :blushing: is that the drive letter is assigned anyway as long as a partition entry is created in the MBR (or in the EPBR), so all it is needed is to add a condition that triggers the format if DR.FileSystem equals whatever vbs returns for a drive not formatted, cannot say if "", 0, -255, "a suffusion of yellow", or anything else, something like *PSEUDO* CODE:

If InStr(1,DR.FileSystem,"<whatever is returned on an unformatted volume>",1) Then

:)

jaclaz

Share this post


Link to post
Share on other sites

I'm not sure that it can determine an unformatted drive, (I'm not even sure if it can determine CDFS). If that is the case then you'd have to use If Not InStr with NTFS and potentially also FAT32 to highlight any drive not formatted as either of those two and format if True.

Share this post


Link to post
Share on other sites

this is getting complicatted because i don't know anything of script programming :(

its not possible if when the script try to create the folder in the destination drive and it gives error then

ask for format drive?

thanks

Share this post


Link to post
Share on other sites

This is my final script.

Its not perfect, but it works well.

PS: The dialogs are in Portuguese.

Many thanks to all of you


<TITLE>Alterar Pastas Pessoais </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:12pt;
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:10pt;
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:9pt;
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 - Documentos", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Pictures - Documentos\Imagens", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music - Documentos\Música", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Video - Documentos\Vídeos", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal - Documentos", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures - Documentos\Imagens", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music - Documentos\Música", _
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Video - Documentos\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("Introduza uma letra da unidade" & vbcrlf & "Error Number 1")
Else
alert("Atenção, caso a unidade " & Drv & " não esteja formatada, terá que a formatar no passo seguinte. Caso contrário, feche a janela da unidade " & Drv & " que irá aparecer.")
Act.Run("explorer " & Drv)
alert("Prima OK para continuar")
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("Alteração concluída com sucesso")
onclick=window.close()
End If
End Function
</SCRIPT>
<BODY Scroll='No'>
<TABLE Style='Margin-Top:3;Margin-Bottom:5;'>Alterar Musica, Documentos, Imagens e Vídeo</TABLE>
<TABLE><TD Class='Txt' Style='Width:161pt;'>
Indique a unidade para onde pretende mover os Documentos</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)'>Alterar</BUTTON>
</TD><TD>
<BUTTON ID='Btn02' onmouseover="this.className='B1'" onmouseout="this.className=''" onclick='window.close();'>Cancelar</BUTTON>
</TD></TABLE>

Edited by Yzöwl
CODE tags added

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...