MSFN Forum: Script to move folder - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Script to move folder Script to move folder Rate Topic: -----

#1 User is offline   quinla01 

  • Newbie
  • Group: Members
  • Posts: 23
  • Joined: 23-February 04

Posted 07 March 2006 - 09:58 AM

Hi guys, I'm not a scripter however someone kindly wrote the below script for me a while back. It allows me to enter a username (via input box) and moves the related home directory from the user Home Directroy Folder to a subfolder named "disabled folders". I'm now in the situation were i have a text file of 900 users. I was hoping somone could help me ammend the script to use the text file as username input.

==================================

Dim strUserName, objFSO

strUserName = ""
strUserName = InputBox("Enter User Name", _
"Migrate User Profile", strUserName)

Set objFSO = CreateObject("Scripting.FileSystemObject")


IF objFSO.FolderExists("\\sspct-fs01\users$\"&strUserName) THEN

IF Not objFSO.FolderExists("\\sspct-fs01\users$\disabledusers\Mig."& strUserName) Then

objFSO.MoveFolder "\\sspct-fs01\users$\"& strUserName , "\\sspct-fs01\users$\disabledusers\Mig."& strUserName

'WScript.Echo "The profile has been renamed: Mig."&strUserName & " and moved to the location \\sspct-fs01\users$\disabledusers"

ELSE WScript.Echo "The folder del."& strUserName & _
" Already exist in the within the folder \\sspct-fs01\profiles$\MigratedProfiles.Manually delete the older profile and try again"

End If

ELSE

WScript.Echo "The profile folder " &strUserName & " does not exit"

End If



=================================


Thanks Guys

Andy


#2 User is offline   tguy 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 698
  • Joined: 19-May 04

Posted 07 March 2006 - 10:05 AM

Try replacing the Inputbox code with this:

Set objArgs = WScript.Arguments
Const ForReading = 1
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(objArgs(0), ForReading)
i = 0
Do While objTextFile.AtEndOfStream <> True
strNextLine = objTextFile.Readline
objDictionary.Add i, strNextLine
i = i + 1
Loop

Then pipe the file name of your text file to the end of the script execution. For example. Users.vbs Users.txt

#3 User is offline   quinla01 

  • Newbie
  • Group: Members
  • Posts: 23
  • Joined: 23-February 04

Posted 08 March 2006 - 04:48 AM

Tried it however it tells me that the directory already exists. Is the main code meant to be placed somewere within your code?

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy