Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

does anyone see the issue with this script?


  • Please log in to reply
10 replies to this topic

#1 chromebuster

chromebuster

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:02:56 PM

Posted 04 September 2010 - 03:25 PM

Here is the script. Maybe you folks can find the bad character so that I can fix it. Thanks.

As follows:
' get the name of the server to check
varServer = InputBox ("Server name to check")
' Get the local path of the file to check
varFile = InputBox _
("Full path and filename of the file on the" & _
"Server (use the local path as if you were at the" & _
"Server console)")
' bind to the server's file service
set objFS = GetObject("WinNT://" & varServer & "/lanmanserver,fileservice")
' scan through the open resources until we 
' locate the file we want
	 varFoundNone = True
' use a For...Each loop to walk through the
' open resources
For Each objRes in objFS.resources
' does this resource match the one we're looking for?
if objRes.path = varFile then
'We found the file -show who's got it
varFoundNone = False
WScript.Echo objRes.Path & " is opened by" & objRes.User
End If
Next
' if we didn't find the file open, then display a MSG
if varFoundNone = True then
WScript.Echo "Didn't find that file open by anyone."
End If

Edited by groovicus, 05 September 2010 - 10:30 AM.
added code tags

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge


BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:56 PM

Posted 05 September 2010 - 10:31 AM

Maybe you could tell us what it is doing that makes you think it doesn't work.

#3 chromebuster

chromebuster
  • Topic Starter

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:02:56 PM

Posted 05 September 2010 - 06:46 PM

What happened was, even though I didn't have any network shares set up to test it against, I was still able to click through the prompts to make sure that nothing was messed up syntactically. Like at the third prompt, WSH comes up and says that at line 9, I have a null character. I spent a bit of time counting down the lines, and for some strange reason, I couldn't find where any of the characters were null. All I know is that I have no idea where that error was pointing to.

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge


#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:56 PM

Posted 06 September 2010 - 11:05 AM

You need to see if the variables in line 9 actually represent any values. Print them out to the screen. My guess is that you are getting a null value because the string you are trying to build is pointing to something that doesn't exists, or one of the variables does not contain the information that you think it does.

#5 chromebuster

chromebuster
  • Topic Starter

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:02:56 PM

Posted 10 September 2010 - 11:55 PM

Hey again,
I was just wondering, from your quick look above, did you see anything that looks a little odd? Maybe I could start there.

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge


#6 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:01:56 PM

Posted 11 September 2010 - 02:04 AM

You assign an object to a variable. What if something goes wrong. You can use IsObject() function to check (if my memory is not failing me).

#7 chromebuster

chromebuster
  • Topic Starter

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:02:56 PM

Posted 05 October 2010 - 03:58 PM

Strangely enough, I copied that script right out of a book. I was typing it in by hand, but I copied every line from the pages. Have you ever seen a programming or scripting book where the scripts and programs do not work? And if I were to switch out one of the lines above for the IsObject() function, where in the current script would I use it? Thanks.

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge


#8 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:56 PM

Posted 05 October 2010 - 05:53 PM

Have you ever seen a programming or scripting book where the scripts and programs do not work?


Would you be shocked if I told you that the number of times a they didn't work was waaaaaaaaay more than the times they actually did work?

#9 chromebuster

chromebuster
  • Topic Starter

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:02:56 PM

Posted 07 October 2010 - 04:23 PM

Actually, yeah I would. You'd think that since these books are usually written by folks who represent the companies who came up with the technologies, you'd think that they did work. And this guy is a MS rep. But I have another book on it at home that was written by Microsoft Corp directly, so I think I'll stick with those from now on. Thanks for the enlightenment though! Holy cow! I've never thought of that!

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge


#10 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:01:56 PM

Posted 08 October 2010 - 07:09 PM

I do not find any error in the code syntax-wise. But this code would work only if you have access to certain network resources.

This MSDN example shows how to check for this kind of error and show error.
http://msdn.microsoft.com/en-us/library/aa...v=VS.85%29.aspx

#11 chromebuster

chromebuster
  • Topic Starter

  • Members
  • 899 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:the crazy city of Boston, In the North East reaches of New England
  • Local time:02:56 PM

Posted 08 October 2010 - 11:28 PM

I think the guy who wrote the book really jumped the gun then since I have no idea what that article's talking about. I'm sure i'll learn it in time though. Thanks a lot though. As i said, it will definitely come in handy in the future.

The AccessCop Network is just me and my crew. 

Some call me The Queen of Cambridge





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users