Computing.Net > Forums > Programming > I need a script. Kinda Urgent.

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

I need a script. Kinda Urgent.

Reply to Message Icon

Name: RAMPKORV
Date: August 8, 2003 at 05:15:25 Pacific
OS: Windows XP Professional
CPU/Ram: PEntium 4 Northwood 2,4Gh
Comment:

This is an annoying problem. I have a text file containing full path and filenames to files I need to copy. Each on its own line. Used replace in wordpad to make a Batch (.BAT) file to copy the files. For some reason though, I seemed to be unable to access the directory from DOS prompt (It's some network drive BTW). Instead, I made a VB-script that looped though the file and did a LINE INPUT and then used a copy function. There is a problem with windows scripting host on this computer, so my program hung on this line:

Open "test.txt" For Input As #1

.. The scripting host didn't like FOR, so I guess it's just something wrong with the scripting host.
It's a really annoying problem, because I would have fixed it some time ago, if I only had VB on this computer, or if Windows Scripting Host worked or access from cmd.exe.

I need n00b Help ;P



Sponsored Link
Ads by Google

Response Number 1
Name: Infinite Recursion
Date: August 8, 2003 at 10:25:51 Pacific
Reply:

Well... I think I will go with your initial attempt on the BAT file on this one. Too much VB going on here these days...

To assign a drive letter to your network drive use the NET USE command (line 2 of script). Then just do your normal DOS commands for copying or other operations you need. Then delete the drive letter assigned to your mapped network drive using the /DELETE option on the NET USE command (line 5 of script)

Beowulf is my system name, MyShare is the directory I want to map as a drive. username is a system variable containing my name for authorization.

---------- SCRIPT -------------------

echo off
NET USE X: \\Beowulf\MyShare /USER:%username%
XCOPY X:\test.txt C:\BIN
DEL X:\test.txt
NET USE X: /DELETE
pause

-----

That should work out for you... Let me know.

Infinite Recursion


0

Response Number 2
Name: Mark
Date: August 12, 2003 at 10:41:03 Pacific
Reply:

In addition, it might be that Windows didn't like long file/folder names with spaces in them. Try enclosing the full path in speech marks:

"c:\program files\another folder\a big file.doc"


0

Response Number 3
Name: Chi Happens
Date: August 13, 2003 at 16:59:46 Pacific
Reply:

You are assuming too much. if you use:

open FileName for input as #1

then the file id 1 MUST be available (which may not always be the case)

try this:
Dim FileID As Long
FileID = FreeFile()
Open "test.txt" For Input As #FileID

then read the file and stuff.

One last note: I haven't done a ton of VBScripting (as far as VBS) but in some flavors of VB (such as ASP pages) you cannot Dim variables AS ANYTHING, not can you use NEXT {Variable} in those cases you have to do this:

'Dim Example
Dim FileID

' For Example
For T = 0 To 100
Next ' Leave off T

Oh and since I mentioned that, I should also mention that within ASP you cannot use

Open FileName For Input As #FileID

You have to use an FSO

Dim FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
FSO.OpenTextFile "test.txt", 1

' do stuff with the file
Set FSO = Nothing

and this will only work if the server allows you to A) Create Objects and B) Create a FileSystemObject (which some don't allow since you can also do FSO.DeleteFolder)

Hope this helps you some,
Chi Happens



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: I need a script. Kinda Urgent.

I need a script for parsing data :) www.computing.net/answers/programming/i-need-a-script-for-parsing-data-/14619.html

i need a script www.computing.net/answers/programming/i-need-a-script/18833.html

I need a script www.computing.net/answers/programming/i-need-a-script/6349.html