topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 2:45 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: A script in cmd to tell if the logged in user has admin rights  (Read 3452 times)

ewhitchu

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
I have used in a script, the technique:-
 mkdir \\%computername%\admin$\tester
IF NOT EXIST \\%computername%\admin$\tester\. goto noADMIN
rmdir \\%computername%\admin$\tester
set admin=true
exit /b 0
:noADMIN
set admin=false
exit /b 1

This works for XP and Windows 7 but I do not seem to be able to get it to work in Vista. Any solution that works across all platforms?

I am limited to just command shell, as clients often disable c/wscript and/or powershell.

AbteriX

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,149
    • View Profile
    • Donate to Member
Don't know, but: Is the Admin$ share is enabled on the Vista box too?

ewhitchu

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
Hi,

Generally the admin$ share has to be specially activated in Vista (not Windows7 however). Even having done that (a registry hack), the code sample fails.

I have a set of install scripts that must be run in command shell on network-connected systems, because some of my clients still will not allow WSH or Powershell at their sites!! I need a way of deciding if the user doing the install has admin rights before starting it.

There are several MSI installs and some dll registration and file copying involved, so I cannot simply make it one MSI.

Looks like I will have to spend a lot more time and make it a full installer so that I can raise the privilege myself.