Run as Admin, Environ, FileExist vs Dir

FuzMic

DataBase Tinker
Local time
Tomorrow, 04:04
Joined
Sep 13, 2006
Messages
744
Hi members

3 in 1 indulgence at one go ;)

1)
I want to do a "net stop spooler". if i use shell i can run it within a .cmd file.

But in Win7 onwards, i think i need to do it with Admin rights.
*Q**How can I within Access VB6 run the .cmd with Admin rights.

2)
Also i want to "del %windir%\system32\spool\printers\*.*". Access does not handle %windir%, so i use Environ("SystemRoot").
**Q*What is the environString for C:\windows\system32 directly?
**Q* Kill do one file at a time, Del allows wild card; Beside Del what else can i use?

3)
FileExist via ms Scripting.Runtime only check one file at a time while Dir can use wild card eg *.s*.
**Q*What are the pros & cons of using Dir in VBA.
**Q* Can FileSystemObject do wild card checking
 
in access vba there are about 50 environ settimngs

try this to see the settings available.

Code:
for x = 1 to 50
   msgbox environ(x)
next
 
Last edited:
Thanks Dave, so neat and easy.
 
FuzMic, just be aware that your #2 item overlaps another post. You are new here so take this as a gentle reminder that we dislike cross-posting the same problem twice.

*Q**How can I within Access VB6 run the .cmd with Admin rights.

First, VB6 isn't Access, it is VBA. There is a technical difference.

Second, it would depend on your session privileges as to whether you could run a shell (or anything else, for that matter) as Admin because "Can use RunAs" is a session privilege setting. Limiting yourself to Access, you cannot choose to run something as Admin unless Access is running as Admin. You have to have outside help (in the form of Windows privileges).
 
Dr don't understand the exact meaning of cross posting; do you mean my latest post overlap with something i posted earlier.

Is it not right that for all coding purposes VB6 & VBA is the same? This does not mean i don't agree with your statement; i just like to know some of key differences so i can really treat them differently. I use to solve my problems in vbforums as if vb6 & vba is the same.

I actually tried to run as Admin with an Access .mde by setting the option in the link. But the link does not allow me to do the setting.
For clarification: if the user is the Admin, is it not Access is running with Admin rights.

Cheerio!
 
Is it not right that for all coding purposes VB6 & VBA is the same?

Technically they are not the same. VBA can ONLY be used to create functions, data structures, and subroutines. VB6 can create whole programs because VB6 can create a main entry point. For VBA, Access is your entry point. VBA cannot be used to create a .DLL file but VB6 can do that.

Yes, your #2 point cross-posts with something else. Like I said, you are new here and we can cut you some slack. But generally the idea is frowned upon to ask the same question twice in two different threads.

Yes, if the Admin user is running Access then Access is probably running with Admin rights (inherited from its user.) However, the question remains as to whether the rights are full Admin rights or constrained Admin rights. At my last job, I was running mostly (but not completely) as Admin. We were not allowed to do certain things that were deemed to be the province of our security wonks. So our domain admins changed our accounts to be "special" Admins. Not sure about exactly which rights weren't there, but if you have a security group to contend with, you might gently inquire as to whether they nailed down some things that admins normally would do.
 
Always thank you for the care to pen your views. Now a better understanding between VB6 & VBA and will not make the same careless reference.

As to the Admin right issue, background to this, if you recall:
i was using 3 win 10 Acer tabloid, on the day before i try to access the C:\windows\system32\spool\printers\. I was just checking if there is any files there.
I first use Dir, it return an err of 52 or bad file name / No.
Next using Filesys the folder.files.count was rejected a err 70 or Permission denied.
I then asked myself how is it the only user to the tabloid with full admin right cannot read this folder. And it happened on ALL 3 tabloid.


BUT TODAY
When i turn on the 3 tabloids there is no more err52 or err70 AND i did nothing to the tabloids.
This is really confusing me.
 
There was a sizeable win 10 update in the last 24 hours.
It has broken one machine here, in a very odd fashion. If it's fixed 3 of yours then maybe the Karmic balance of the world is okay :)
 
FuzMic, it would pay you to remember and take note of this fact revealed by Minty. Whenever Microsoft publishes patches, it is a fair bet as to what they will break in program B when they fix program A. Not even odds, but nowhere near zero odds either. Which is why I have my systems notify me that patches are available. I still think that most of the time, patches are GOOD things - but I want to know about it if I have to roll back a patch or take other remedial action. Call it a "cost of doing business with Microsoft."
 
Thanks guys, patch by all means we are but fallible humans. :cool:
 

Users who are viewing this thread

Back
Top Bottom