Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


how to make this script to copy the file to "%programfiles%"

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,34026
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> how to make this script to copy the file to "%programfiles%"
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 how to make this script to copy the file to "%prog... - 4/27/2006 6:22:09 AM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
Hello,

i have this script and i want that the file\folder will be copied to the "%programfiles%" and not like this script write to the "D:\Archive"

Const FOF_CREATEPROGRESSDLG = &H0&

ParentFolder = "D:\Archive"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "C:\Scripts", FOF_CREATEPROGRESSDLG

i must say that i'm real newbie, so Plz if you can change the script that the folder will be copied to the  "%programfiles%" it will be very helpful.
 
 
Post #: 1
 
 RE: how to make this script to copy the file to "%... - 4/27/2006 6:30:20 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
Try:

Const FOF_CREATEPROGRESSDLG = &H0&

Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
ParentFolder = oWsh.ExpandEnvironmentStrings("%ProgramFiles%")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "C:\Scripts", FOF_CREATEPROGRESSDLG

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to avipenina)
 
 
Post #: 2
 
 RE: how to make this script to copy the file to "%... - 4/27/2006 8:33:28 AM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
quote:

ORIGINAL: ebgreen

Try:

Const FOF_CREATEPROGRESSDLG = &H0&

Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
ParentFolder = oWsh.ExpandEnvironmentStrings("%ProgramFiles%")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "C:\Scripts", FOF_CREATEPROGRESSDLG


Thanks
man you are great, it's working fine, last question how on the same script i can tell him to copy the folder into "%ProgramFiles%" and "windir"  together ? 

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: how to make this script to copy the file to "%... - 4/28/2006 12:18:52 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Didn't you already ask this in another post?
http://www.visualbasicscript.com/fb.aspx?m=33843

(in reply to avipenina)
 
 
Post #: 4
 
 RE: how to make this script to copy the file to "%... - 4/28/2006 2:29:18 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
You see what you did to copy it into program files? Do that again only tell it windir this time.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Country73)
 
 
Post #: 5
 
 RE: how to make this script to copy the file to "%... - 4/28/2006 5:51:25 AM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
quote:

ORIGINAL: ebgreen

You see what you did to copy it into program files? Do that again only tell it windir this time.


but i want to copy the file into the "%ProgramFiles%" and "windir"  together
i can't do that because it doesn't copy the file to the 2 places, how i can fix this?

Const FOF_CREATEPROGRESSDLG = &H0&

Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
ParentFolder = oWsh.ExpandEnvironmentStrings("%ProgramFiles%")
ParentFolder = oWsh.ExpandEnvironmentStrings("%windir%")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "C:\Scripts", FOF_CREATEPROGRESSDLG

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: how to make this script to copy the file to "%... - 5/1/2006 1:25:54 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
Do the whole process twice. Not just the environment expansion.

Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
ParentFolder = oWsh.ExpandEnvironmentStrings("%ProgramFiles%")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "C:\Scripts", FOF_CREATEPROGRESSDLG

ParentFolder = oWsh.ExpandEnvironmentStrings("%windir%")
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "C:\Scripts", FOF_CREATEPROGRESSDLG

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to avipenina)
 
 
Post #: 7
 
 RE: how to make this script to copy the file to "%... - 5/1/2006 3:51:24 AM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
ok thanks, i thought that there is shortcut for this code.

(in reply to ebgreen)
 
 
Post #: 8
 
 RE: how to make this script to copy the file to "%... - 5/1/2006 4:19:07 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
Well, if you had a lot of directories, then you could put the list of directories into an array and iterate through the array doing the code for each directory but that is overkill for two directories and three lines of repeated code.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to avipenina)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> how to make this script to copy the file to "%programfiles%" Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts