|
I'm stumped on something that should be simple, but.....
I've written a VBscript to create a folder on an IOMega NAS box using objFSO.CreateFolder, and copy some files to it for backup. It runs on a server using Win2003R2. The NAS box is mapped to a local drive letter on this server.
I use cscript to run the script, fired off by the scheduler at night, under an Administrator user ID.
The script works fine in debug mode.
If I execute the script from a Run|cmd command line, it works fine.
When kicked off by the scheduler, it always fails on the CreateFolder method with a 76 error (path not found).
But if I open the scheduler, right click on the job and select "Run", it runs the job with no problems and completes successfully!
I've inserted some debug code before the CreateFolder, checking for FolderExists on the NAS box and that is always successful. The first hint of trouble is the 76 error on the CreateFolder method.
Here's some of the code. "x" is the mapped drive.
BTW: all of the code referencing "NAS disks to spinup" was added to get around this 76-error problem, under the assumption that idled disks were the culprit; none of it helped.
Const Backupfolder = "x:\Data Backups"
.
.
.
' Checking to see if NAS disks are still spinning
If objFSO.FolderExists(Backupfolder) Then i=1
writelog ("check that NAS disks are spinning: err.num: " & Err.Number & " " & Err.Description)
errHandler ("checking if NAS disks are spinning")
' Generate today's directory name in the format yymmdd
strmonth = month(date)
if strmonth < 10 then strmonth = "0" & strmonth
strday = day(date)
if strday < 10 then strday = "0" & strday
todaysfolder = right(year(date),2) & strmonth & strday
' Now create the full pathname to today's backup folder
todayspath = Backupfolder & "\" & todaysfolder
' Create todays backup folder
If objFSO.FolderExists(todayspath) Then
Set objbkupFolder = objFSO.GetFolder(todayspath)
writelog(todayspath & " already exists!")
Else
writelog("Creating folder " & todayspath)
Err.Clear
Set objbkupFolder = objFSO.CreateFolder(todayspath)
If Err.Number <> 0 Then
writelog ("Waiting 15 seconds for NAS disks to start. Err: " & Err.Number & " " & Err.Description)
Err.Clear
objbkupFolder = nothing
Wscript.Sleep 15000 'Wait 15 seconds for NAS disks to spin up
Set objbkupFolder = objFSO.CreateFolder(todayspath)
If Err.Number <> 0 Then
errHandler (" trying to create folder " & todayspath)
abendscript
End If
End If
End If
Anybody have any ideas on this?
Jeff
|
|
|
|
|
It doesn't work because the drive mapping doesn't exist under the scheduler's user session. You have to provide code in the script for mapping the drive, or just skip the drive mapping and recode the script to use UNC paths instead.
|
|
|
|
|
Changed to UNC addressing. Works like a champ now. Thanks
|
|
|
|
|
when working wit winservice will it be better to use timer or thread
|
|
|
|
|
The two are completely different concepts that do not apply to the same thing. What are you trying to do??
|
|
|
|
|
i am trying to manipulate database. insert, update and select using winservice programme
|
|
|
|
|
Hi,
if it has to work in the background and is not related to time, just use one or more extra threads.
if it is time related (e.g. a periodic action), use a timer.
|
|
|
|
|
|
I've been given a project to run/update a spreadsheet using VBA/Excel. When I try to run the macros I keep getting the following erro:
Run-time error '91':
Object variable or With Bock cariable not set
I have no idea what to do and I have not used VBA!
Here is where the trouble starts**:
Ensure all Active projects are in the "All" Sheet
With g_wksIOProjects
**For lngRow = 2 To .UsedRange.Rows.Count
If .Cells(lngRow, 28).Value = "COMMITTED" And _
.Cells(lngRow, 5).Value <> "Execution (PEM) - On hold" Then
If InSheet(g_wksALL, 2, .Cells(lngRow, 1).Value) = False Then
Call WriteMessage("Committed project missing from 'All', " & _
.Cells(lngRow, 1).Value & ": " & .Cells(lngRow, 3).Value, Mess.Critical)
End If
End If
If .Cells(lngRow, 28).Value <> "COMMITTED" And _
.Cells(lngRow, 28).Value <> "CANCELLED" And _
.Cells(lngRow, 28).Value <> "CLOSE" And _
.Cells(lngRow, 28).Value <> "NOT SUBMITTED" And _
.Cells(lngRow, 14).Value > 50 Then
If InSheet(g_wksALL, 2, .Cells(lngRow, 1).Value) = False Then
Call WriteMessage("Project with significant recorded effort missing from 'All', " & _
.Cells(lngRow, 1).Value & ": " & .Cells(lngRow, 3).Value & _
", Hours = " & .Cells(lngRow, 14).Value, Mess.Critical)
End If
End If
Next lngRow
End With
|
|
|
|
|
Sounds like .UsedRange.Rows.Count is not set when you run your code.
Do you need to select your range first?
|
|
|
|
|
What is the Worksheet name you are referencing?
With ActiveSheet
For lngRow = 2 To .UsedRange.Rows.Count
....
Next
End With
Try this with the workseet active.
I don't speak Idiot - please talk slowly and clearly
|
|
|
|
|
Is there a big difference between vb6 and vb.net as far as coding and design?
|
|
|
|
|
You simply can not compare them...
The only resemblance is the sintaxe every thing else is completly diferent
Sérgio Lima
Many people would sooner die than think; In fact, they do so.
- Bertrand Russell
|
|
|
|
|
|
There are differences between VB6 and VB.NET. VB6 has been dead, and unsupported by Microsoft since about March 2005. VB.NET is more closer to be really object oriented than VB6.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
VB6 is a muddled mess of a language which is saddled with oodles of quirks which were designed to make it somewhat compatible with QuickBasic and QBASIC, which were in turn designed to be compatible with the original IBM PC Cassette BASIC. Although it "looks" object-oriented, it lacks features like inheritance which are necessary to make real object-oriented programming possible. Further, as a result of its Cassette BASIC roots, many object methods have strange and bizarre variations in syntax which cannot be mimicked with user-defined functions. For example, to draw a box on the printer,
Printer.Line(10,10)-(20,20),0,BF
The use of two coordinate pairs, separated by a dash, and the use of the literal characters "BF" (block fill) without any string delimiter, are both perfectly fine syntax in an interpreted language (like Cassette Basic). They're not really any harder to parse than would be "LINE 10,10,20,20,0,2" (the "3" being "BF") and they're easier to read, but syntax line that makes it impossible to create a function that behaves like the "Line" function.
|
|
|
|
|
|
The only similarities are that they both have "Visual Basic" in the title and the message box function is MsgBox() in both.
|
|
|
|
|
The JZ wrote: and the message box function is MsgBox() in both
Actually, the message box method in .NET is MessageBox.Show. The MsgBox method in VB.NET is just a wrapper for the MessageBox.Show method.
Also, it's far from the only VB 6 leftover. VB.NET has a lot of wrappers with the same name as the VB 6 functions, that call the corresponding .NET method.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Like Charlie Brown, all I can say is "Good Grief!"
|
|
|
|
|
I think he gets the point!
|
|
|
|
|
hi jds1207
When i heard there was vb.net, i was in vb6, and i thought, no am happy here at vb6, and i was so Stuborn and never wanted to Listen when they told me about vb.net, One day i had a problem in my code and i post a thread in a forum and i wrote something like " i have problem inserting records in vb", well the person who answered me, thought i was using vb.net and he posted an example code of vb.net, am telling you it was Completely different and made sense than my vb6 code. Initialy i thought i was going to learn there and there and grasp the language, but i was lying to myself, i had to start learning the Language from Scratch , and till today i dont see vb6 come Closer to vb.net. The Syntex might look alike but they are Completely Different.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Nevertheless, the transition from VB6 to VB.NET is easier than from being a non-programmer to VB6.
|
|
|
|
|
you are Very Correct
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
To start off their is no comparison
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|