Run file check script as specific user

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 11 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ltcloud
Posts: 3
Last visit: Mon Aug 27, 2012 6:13 am

Run file check script as specific user

Post by ltcloud »

Hi, hew here. I have put together a very basic file check script to make sure that our computers are mapped to the proper shared drive. However, all of the machines are mapped as Administrator, and sometimes the script runs on other user accounts, which sends back an error.

Basically I want to run the script on the Administrator account only to check to see if file exists (ie M:Share)

Any help is appreciated.
User avatar
ltcloud
Posts: 3
Last visit: Mon Aug 27, 2012 6:13 am

Run file check script as specific user

Post by ltcloud »

Hi, hew here. I have put together a very basic file check script to make sure that our computers are mapped to the proper shared drive. However, all of the machines are mapped as Administrator, and sometimes the script runs on other user accounts, which sends back an error.

Basically I want to run the script on the Administrator account only to check to see if file exists (ie M:Share)

Any help is appreciated.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Run file check script as specific user

Post by jvierra »

What you are asking doe not make much sense from an administrative perspective.

Share are mapped by a user account. Shares can usually only be created by an admin.

M:share is not a share it is a drive and a folder or file.

You need to try and state your question in a less ambiguous way.
User avatar
ltcloud
Posts: 3
Last visit: Mon Aug 27, 2012 6:13 am

Run file check script as specific user

Post by ltcloud »

The logic in my current script basically says,
Check if M:Shareconfig.txt exists
Exit script on success, send e-mail on fail.

If M: is not mapped to C:FilesShare, then I want to be alerted.
M: is only mapped to that folder location on the Administrator account. My problem is, the script runs on different accounts at times, and I want to specify which user account to use.

So I am telling the script
Check if AdministratorM:Shareconfig.txt exists


I'm not really sure how to be more clear. I just want it to ignore secondary user accounts. And if it helps create clarity, I am using an RMM tool to run these scripts on multiple machines remotely.ltcloud2012-08-27 13:16:26
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Run file check script as specific user

Post by jvierra »

What do you mean you wan to ignore secondary user accounts? GRoup Policy is no a good place to do this. It is not what GP is for.

YOu can run a script under the scheduler to check if a share exists. What you ar4e chieckin is if a file exists. If yu want to test a share just fo:
if(Test-Path servershare){
.... share exists
}else{

... share does not exist.
}

In DOS you can use:net use |findstr I "m:.*\devws2downloads"

This will check to be sure the right drive is actually connected to the correct share.

If the share is not correct it will set ERRORLEVEL to non-zero.

Logon scripts are set in many ways. You failed to say how you have this Logon script defined. In GP you can use filtereig to target specific accounts and in GP Prederences you can set usera ccount targetting to select speciifc accounts or groups for mapping drives or for running scripts.


This topic is 11 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked