Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


%userprofile% and %systemroot%?

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> %userprofile% and %systemroot%?
  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 >>
 %userprofile% and %systemroot%? - 11/18/2006 9:51:36 AM   
  Goldencat

 

Posts: 8
Score: 0
Joined: 11/10/2006
Status: offline
I want to be able to use FileSystemObject, as well as other things, to copy a file to a computer's dynamic user profile folder.  In Batch one could simply write %userprofile%, and the computer would return "C:\Documents and Settings\etc\".  I've attempted to use %userprofile% and %systemroot% in VBScript, but it doesn't understand them.  Could anyone help me use the VBScript equivalent of %userprofile% and %systemroot%?

Thank you.
 
 
Post #: 1
 
 RE: %userprofile% and %systemroot%? - 11/18/2006 11:22:51 AM   
  themanwhowouldbeking

 

Posts: 4
Score: 0
Joined: 11/15/2006
Status: offline

The below will return the user profile and system root variables within a VB script.
 

Set
oShell = CreateObject("Wscript.Shell")
strUserProfile = oShell.ExpandEnvironmentStrings(
"%USERPROFILE%")
str
WinDir = oShell.ExpandEnvironmentStrings("%SYSTEMROOT%")

< Message edited by themanwhowouldbeking -- 11/18/2006 11:27:27 AM >


_____________________________

2O LEGEND

(in reply to Goldencat)
 
 
Post #: 2
 
 RE: %userprofile% and %systemroot%? - 11/19/2006 6:30:22 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
Dim WshSysEnv
Set WshSysEnv = WshShell.Environment("Process")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Copy the files from the network to the Client computer and Rename the folder to folder1 to whateveryouwant
objFSO.CopyFolder "\\server\share", WshSysEnv("%SystemDrive%") & "\Program Files\folder\folder1", overwrite = True

(in reply to Goldencat)
 
 
Post #: 3
 
 RE: %userprofile% and %systemroot%? - 11/20/2006 9:27:50 AM   
  Goldencat

 

Posts: 8
Score: 0
Joined: 11/10/2006
Status: offline
It works, thank you.

(in reply to gdewrance)
 
 
Post #: 4
 
 
 
  

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 >> %userprofile% and %systemroot%? 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