Sign in to follow this  
Followers 0
cpremo

Searched but can not find Help

2 posts in this topic

#1 ·  Posted (edited)

I've tried to create a script that will enable me to "push" a file copy to the "C:\Windows" directory as an Administrator of the PC. This is needed because most users only have "User" rights to the PC and we want to be able to copy a BMP file that will be use to update the Login Dialog box with a "Security" message. Unfortunately, the C:\Windows directory is "Read Only" for "User" accounts and they can't copy files to that location. Thus the need for the script. I tried these two scripts to do this, but have failed miserably. Any help will be greatly appriciated. (And yes, I know we shouldn't include the password, but . . . how else can we do it without user interaction?)

;Using the @ScriptDir option enables this program to run from any location and work.
;You only have to ensure the folowing three files are located in the same directory:
;ClientLogo.exe, ClientLogo.ini and the Banner BMP file you will use (as referenced
;in the ini file).

;This If statement determines whether the user is logged is an administrator.
;If the user isnt an administrator, then it uses the information shown to run
;the process.
If Not IsAdmin() Then
; Fill in the username and password appropriate for your system.
    Local $sUserName = "Administrator"
    Local $sPassword = "password"
    $Domain = @ComputerName
    $Filename = @ScriptDir & "\ClientLogo.exe"
; Run a command prompt as the other user.
    Local $pid = RunAs($sUserName, $Domain, $sPassword, 4, RunWait($Filename), @ScriptDir, @SW_HIDE, 8)
; Wait for the process to close.
    ProcessWaitClose($pid)

EndIf

The first script calls the second script using the "RunWait($Filename)" line. I tried without the "RunWait" and nothing happened.

Using the @ScriptDir option enables this program to run from any location and work.
;You only have to ensure the folowing three files are located in the same directory:
;ClientLogo.exe, ClientLogo.ini and the Banner BMP file you will use (as referenced
;in the ini file).

    Dim $Location
    Dim $Destination
    Dim $FileName
    If @OSVersion = "WIN_2000" Then
;This statement reads data from the referenced INI file to set the paramenter shown.
        $Destination = IniRead ( @ScriptDir & "\ClientLogo.ini", "LogoData", "Destination2", "default" )
    ElseIf @OSVersion = "WIN_XP" or @OSVersion = "WIN_VISTA" Then
;This statement reads data from the referenced INI file to set the paramenter shown.
        $Destination = IniRead ( @ScriptDir & "\ClientLogo.ini", "LogoData", "Destination1", "default" )
    EndIf

;This statement reads data from the referenced INI file to set the paramenter shown.
    $FileName = IniRead ( @ScriptDir & "\ClientLogo.ini", "LogoData", "FileName", "default" )
    $Location = @ScriptDir & "\" & $FileName
    dim $Banner = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\NOVELL\LOGIN\BANNER","IMAGE")

    If not FileExists($Destination & $FileName) Then

        FileCopy($Location, $Destination, 9)

    EndIf
    If $Banner <> ($Destination & $FileName) Then
        RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\NOVELL\LOGIN\BANNER","IMAGE","Reg_SZ", $Destination & $FileName)
    Else
    EndIf
Edited by cpremo

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you open a command prompt you can use runas to execute your script:

runas /user:administrator myscript.exe

EDIT:

Also:

Local $pid = RunAs($sUserName, $Domain, $sPassword, 4, RunWait($Filename), @ScriptDir, @SW_HIDE, 8)

Should be:

Local $pid = RunAsWait($sUserName, $Domain, $sPassword, 4, $Filename, @ScriptDir, @SW_HIDE, 8)
Edited by weaponx

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0