Mapped drives and Service accounts


Recommended Posts

Hello, basically I have a situation where a VBScript performs a few against queries a mapped drive. It works perfectly as an interactive sessions (such as my user account). However, I do not want it to require an interactive logon, I want it to run as a service account, or something similar, so that it does not require my user input.

 

Here is the layout:

 

1x FreeNAS server with a network share named 'Share1'

1x Windows Server 2008 R2 with a mapped Z:\ drive connecting to \\FreeNAS\Share1. I log onto this Windows Server and run a vbscript that performs queries against the Z:\ mapped drive.

 

Can this be performed without an interactive logon?

Link to comment
Share on other sites

Where you can run into an issue is if this location your running the script from has other sessions open to this freenas, lets say billy is logged into the box where the script runs and has a connection to this freenas\share1 -- you can not create another session to freenas from the same location with different credentials.

 

Its quite possible to create the session using whatever creds you want in your script to access the resource -- but if that source has other sessions open to that server your most likely going to have issues.  You normally can not have multiple sessions to the same server from the same location with different creds.

Link to comment
Share on other sites

Where you can run into an issue is if this location your running the script from has other sessions open to this freenas, lets say billy is logged into the box where the script runs and has a connection to this freenas\share1 -- you can not create another session to freenas from the same location with different credentials.

 

Its quite possible to create the session using whatever creds you want in your script to access the resource -- but if that source has other sessions open to that server your most likely going to have issues.  You normally can not have multiple sessions to the same server from the same location with different creds.

Thanks for your reply. The script would only be ran once a day to query the free space remaining on the drive, so there isn't an issue with different credentials. However, I do not wish a user to be logged in at all, just having it run as a service account. However I do not think that service accounts can map z:\freenas\share1, as it isn't interactive.

Link to comment
Share on other sites

run it as a scheduled task, you won't neet to be logged in with anyone, it will just run.  You can schedule it to run once a month, once a week, once a day, once every minute...alternate months, weeks, days, hours, minutes, etc.  I would think that would be better for you than run as a service. 

Link to comment
Share on other sites

run it as a scheduled task, you won't neet to be logged in with anyone, it will just run.  You can schedule it to run once a month, once a week, once a day, once every minute...alternate months, weeks, days, hours, minutes, etc.  I would think that would be better for you than run as a service. 

But can I map a Z:\ drive as a scheduled task without anybody logged on?

Link to comment
Share on other sites

Why would you not simply do what you need to do with the unc path vs mapped drives. Drive mapping is for user ease..vbscript should not care between user drive mapping and actual path.

Link to comment
Share on other sites

Why would you not simply do what you need to do with the unc path vs mapped drives. Drive mapping is for user ease..vbscript should not care between user drive mapping and actual path.

Unforutunately I don't know how to do that. All my attempts of using the UNC share have shown the CIFS share as having 0 bytes free. (The same as browsing to the UNC path and selecting properties). However, when it is mapped, Windows knows how large and how much is used of the drive as it acts as a volume, rather than a share. I do not know how to get round this. :(

Link to comment
Share on other sites

You can use powershell instead, and make a small script to query space after mounting it.

 

use a scheduled job like sc302 described.

 

Set the job to run as whoever has access to mount.

New-PSDrive ?Name ?<free driveletter>? ?PSProvider FileSystem ?Root ?\\<nas name>\<sharename>?

Get-Volume <driveletter> | out-file <path to logfile> -append

Remove-PSDrive <Driveletter>

 

make sure the account you are running the job as have the rights to do what you need.

Link to comment
Share on other sites

This topic is now closed to further replies.