1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Defrag rights for restricted user

Discussion in 'Legacy Windows' started by Theonlyq, 2002/02/28.

Thread Status:
Not open for further replies.
  1. 2002/02/28
    Theonlyq

    Theonlyq Inactive Thread Starter

    Joined:
    2002/01/30
    Messages:
    3
    Likes Received:
    0
    Does anyone know how to give permission to allow 'restricted users' to use disk defragmenter?
     
  2. 2002/02/28
    unixfan

    unixfan Inactive

    Joined:
    2002/01/26
    Messages:
    282
    Likes Received:
    0
    Compile an exe using NetExec or call runas in VBScript and encode/encrypt it.
     

  3. to hide this advert.

  4. 2002/03/01
    Theonlyq

    Theonlyq Inactive Thread Starter

    Joined:
    2002/01/30
    Messages:
    3
    Likes Received:
    0
    How exactly would you perform the runas function you stated?
     
  5. 2002/03/01
    unixfan

    unixfan Inactive

    Joined:
    2002/01/26
    Messages:
    282
    Likes Received:
    0
    The syntax for the runas command is:

    runas /user:computername\administrator "mmc dfrg.msc "

    and you will be prompted for the password.

    See also JSI

    Using VBScript SendKeys it is possible to provide the password automatically:

    'vbsrun.vbs
    'modified from here
    Dim exefile, directory, fullpath, user, password, CRLF, windir, cmdpath

    cmdpath = "\System32\cmd.exe "
    exefile = "mmc dfrg.msc "
    'Enter your user and password details here including computername
    user = "computername\administrator "
    password = "PASSWORD "
    CRLF = chr(10) & chr(13)

    Set WshNetwork = WScript.CreateObject( "WScript.Network ")'declaration of a network object
    Set WshShell = WScript.CreateObject( "WScript.Shell ")
    Set WshSysEnv = WshShell.Environment( "PROCESS ")

    windir = WshSysEnv( "WINDIR ")
    cmdpath = windir & cmdpath
    directory = get_current_directory
    fullpath = directory & exefile

    WshShell.Run cmdpath
    WScript.Sleep 100
    WshShell.AppActivate cmdpath
    WScript.Sleep 100
    WshShell.SendKeys "runas /user:" & user & " " & chr(34) & exefile & chr(34) & CRLF
    WScript.Sleep 200
    WshShell.SendKeys password & CRLF
    WScript.Sleep 50
    WshShell.SendKeys "exit" & CRLF
    wscript.quit

    '---------------------------------------------------------------
    Function get_current_directory()

    Dim WshShell, directory, final_directory, pos

    directory = WScript.ScriptFullName
    pos = instrrev(directory, "\ ",-1)
    final_directory = left(directory,pos)

    get_current_directory = final_directory

    Set WshShell = Nothing

    End Function
    '---------------------------------------------------------------

    Copy and paste the above in a file called vbsrun.vbs
    Download encode.wsf and drag and drop vbsrun.vbs on to it to create vbsrun.vbe (encoded)

    vbe files have been cracked but it's better than nothing.

    Create a batch file called RUNVBS.BAT containing the line (include the path to vbsrun.vbe):

    cscript vbsrun.vbe

    Then test it out by running RUNVBS.BAT (only requires vbsrun.vbe and RUNVBS.BAT).
     
    Last edited: 2002/03/01
  6. 2002/03/07
    DaveC

    DaveC Inactive

    Joined:
    2002/03/07
    Messages:
    7
    Likes Received:
    0
    unixfan,

    Thank you very much for your post, this will be a very useful tool for me. I have a question for you. How would you have the script detect the computer name? I have a network of over 100 users and I would like to send one script to all users.

    Thanks in advance
    dave
     
  7. 2002/03/07
    unixfan

    unixfan Inactive

    Joined:
    2002/01/26
    Messages:
    282
    Likes Received:
    0
    Change the first few lines...

    Dim exefile, directory, fullpath, user, password, CRLF, windir, cmdpath, computer

    cmdpath = "\System32\cmd.exe "
    exefile = "mmc dfrg.msc "
    password = "PASSWORD "
    CRLF = chr(10) & chr(13)

    Set WshNetwork = WScript.CreateObject( "WScript.Network ")'declaration of a network object
    Set WshShell = WScript.CreateObject( "WScript.Shell ")
    Set WshSysEnv = WshShell.Environment( "PROCESS ")

    computer = WshNetwork.ComputerName
    user = computer & "\administrator "

    windir = WshSysEnv( "WINDIR ")
    cmdpath = windir & cmdpath
    directory = get_current_directory
    fullpath = directory & exefile

    WshShell.Run cmdpath
    WScript.Sleep 100
    WshShell.AppActivate cmdpath
    WScript.Sleep 100
    WshShell.SendKeys "runas /user:" & user & " " & chr(34) & exefile & chr(34) & CRLF
    WScript.Sleep 200
    WshShell.SendKeys password & CRLF
    WScript.Sleep 50
    WshShell.SendKeys "exit" & CRLF
    wscript.quit

    '---------------------------------------------------------------
    Function get_current_directory()

    Dim WshShell, directory, final_directory, pos

    directory = WScript.ScriptFullName
    pos = instrrev(directory, "\ ",-1)
    final_directory = left(directory,pos)

    get_current_directory = final_directory

    Set WshShell = Nothing

    End Function
    '---------------------------------------------------------------
     
    Last edited: 2002/03/07
  8. 2002/03/07
    DaveC

    DaveC Inactive

    Joined:
    2002/03/07
    Messages:
    7
    Likes Received:
    0
    Thank you very much. This is exactly what I have been looking for.

    Dave
     
  9. 2002/03/07
    DaveC

    DaveC Inactive

    Joined:
    2002/03/07
    Messages:
    7
    Likes Received:
    0
    OK Now that this is working I found another good use for it. How would I launch an .exe file. I know it should be self explanatory but I am getting some errors.

    This is the path and file I am trying to launch
    \\blue-srvr\SYS\public\Client\WNT481e\i386\setupnw.exe

    I have tried to add the path to the file and no luck. The next step was to put the VB file in the same directory(this is really what I was looking for)
     
  10. 2002/03/07
    unixfan

    unixfan Inactive

    Joined:
    2002/01/26
    Messages:
    282
    Likes Received:
    0
    What error(s) are you getting? Does the Novell License agreement appear? Make sure that the runas account has sufficient permissions to the share (try running at the desktop to check). The exefile path can use UNC but try a shorter path or mapping a drive letter.

    Have you tried Novell's ACU.EXE ?
     
  11. 2002/03/08
    DaveC

    DaveC Inactive

    Joined:
    2002/03/07
    Messages:
    7
    Likes Received:
    0
    I think I know why it's not working. I found this on Microsofts site.

    If you try to start a program, MMC console, or Control Panel item from a network location using Run as, it might fail because the credentials used to connect to the network share are different from the credentials used to start the program. The credentials used to run the program may not be able to gain access to the same network share.

    I am on a Novell network so runas can't find the file because I am trying to run this from a network share. I can run any exe file localy but as soon as I try to run it from a share it fails.
    In a nutshell this is what's happening. I am logged into Novell as <username> runas is trying to run as user<install> since install is not authenicated to Novell it can't see the share. What will need to happen is have the scipt logon to Novell first as install then run the program as install on the local computer. Is it possible to logon to Novell with Visual Basic?

    Dave
     
    Last edited: 2002/03/08
  12. 2002/03/08
    unixfan

    unixfan Inactive

    Joined:
    2002/01/26
    Messages:
    282
    Likes Received:
    0
    I don't know anything about NetWare but does it support pass-through authentication? Where you can create a NetWare user and give it rights to the necessary resources, then in Win2k create an identical user with the same name and password and add it to the local admin group.

    You can run LOGINW32 from VBScript shell but I don't think it will help you here.
     
    Last edited: 2002/03/08
  13. 2002/03/15
    DaveC

    DaveC Inactive

    Joined:
    2002/03/07
    Messages:
    7
    Likes Received:
    0
    Is it possible to run this script hidden? I want to do various things VIA logon script but I don't want the users to see whats going on.

    For one thing I want to be able to change the Admin password on the client machines with the command

    NET USERS Administrator <new passwd goes here>

    If the users can see the dialog window they will know the new Admin passwd.

    Thanks
    dave
     
  14. 2002/03/15
    unixfan

    unixfan Inactive

    Joined:
    2002/01/26
    Messages:
    282
    Likes Received:
    0
    runh.exe can run batch files hidden. The VBScript equivalent would be:

    WshShell.Run CommandToRun, 0, FALSE

    However, changing the local admin password could also be achieved by using the GUI tool DCPC .

    Or running AT (scheduler command) or cusrmgr.exe (from the resource kit) in a batch file if you have a list of workstation names (obtained using net view).
     
  15. 2002/03/15
    DaveC

    DaveC Inactive

    Joined:
    2002/03/07
    Messages:
    7
    Likes Received:
    0
    OK When I change to the following line:
    WshShell.Run cmdpath, 0, FALSE

    It opens the Recycle Bin

    Ideas
     
  16. 2002/03/15
    unixfan

    unixfan Inactive

    Joined:
    2002/01/26
    Messages:
    282
    Likes Received:
    0
    No, that was just an example:

    ' test.vbs
    ' change 0 to 1 to see the difference
    option explicit
    dim wshShell
    set WshShell = CreateObject ( "wscript.shell ")
    WshShell.Run "c:\winnt\system32\cmd.exe ", 0, FALSE
    set WshShell = nothing

    Unfortunately, you can't hide the cmd window when using SendKeys. It needs to have the focus.
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.