Jump to content

Trouble with RunAsSet


Recommended Posts

I have this Code:

RunAsSet("Administrator", @Computername, "password")

; Run registry editor as admin
RunWait("C:\Windows\System32\cmd.exe")

; Reset user's permissions
RunAsSet()

It dosen't work. I become this error message:

Error: Unable to execute the external programm.

The directory is wrong (In german (It's a german Windows :) ) "Der Verzeichnisname ist ungültig")

OS: Windows XP

Where is my Bug?

Greetings,

Ralf

CURalf

Link to comment
Share on other sites

RunAsSet("Administrator", @Computername, "password")
RunWait("C:\Windows\System32\cmd.exe")
RunAsSet()

Where is my Bug?

I guess the user Administrator has not enough rights to access the current working directory. Try adding a FileChangeDir('c:\') or specify a different working directory for cmd.exe in RunWait(). Edited by sugi
Link to comment
Share on other sites

RunAsSet("Administrator", @Computername, "enter admin pass here")

; Run registry editor as admin
RunWait("regedit")

; Reset user's permissions
RunAsSet()

Make sure that you are have the correct password for the Administrator account.

To run

Run registry editor

u use regedit not cmd

hope this helps

Link to comment
Share on other sites

I guess the user Administrator has not enough rights to access the current working directory. Try adding a FileChangeDir('c:\') or specify a different working directory for cmd.exe in RunWait().

Thanx! That was my bug!

Edited by Essbaumer

CURalf

Link to comment
Share on other sites

Next Problem. I want to install VNC to a Machine where the user have no rights to install.

Here is my Source:

; ----------------------------------------------------------------------------
; Set up our defaults
; ----------------------------------------------------------------------------

$Anwendung = "VNC Ver.: 4.0 Beta 4"
$AnwendungPfad = "\\VNC_40b4\\vnc-4.0b4-x86_win32.exe"


; ----------------------------------------------------------------------------
; Script Header
; ----------------------------------------------------------------------------

AdlibEnable("myadlib")

FileChangeDir('c:\')

RunAsSet("Administrator", @Computername, "Password")

$MapLW = DriveMapAdd("*", "\\10.40.36.60\Install$", 0)
Run($MapLW & $AnwendungPfad)

; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

WinWaitActive("Setup")
Send("!y")
WinWaitActive("Setup - VNC", "Welcome")
Send("!n")
WinWaitActive("Setup - VNC", "License")
Send("!a!n")
WinWaitActive("Setup - VNC", "SelectDir")
Send("!n")
WinWaitActive("Setup - VNC", "SelectComponents")
Send("{UP}{UP}{UP}{TAB}{DOWN}{DOWN}{SPACE}!n")
WinWaitActive("Setup - VNC", "SelectProgramGroup")
Send("!d!n")
WinWaitActive("Setup - VNC", "Start the VNC Server in Service-Mode")
Send("!n")            
WinWaitActive("Setup - VNC", "Ready")
Send("!i")
WinWaitActive("VNC Server Properties (Service-Mode)", "No Authentication or Encryption")
Send("{TAB}{SPACE}")
WinWaitActive("WinVNC Password")
Send("Ebersberg.AcceSS{TAB}Ebersberg.AcceSS{TAB}{SPACE}")
WinWaitActive("VNC Server Properties (Service-Mode)", "No Authentication or Encryption")
Send("{TAB}{SPACE}")
WinWaitActive("Setup - VNC", "InfoAfter")
Send("!n")
WinWaitActive("Setup - VNC", "Finished")
Send("!f")

; ----------------------------------------------------------------------------
; Script Ende
; ----------------------------------------------------------------------------

DriveMapDel($MapLW)
RunAsSet()

Func myadlib()
    If WinActive("Directory Exists") Then
        Send("!y")
    EndIf
EndFunc

The same Errormessage:

Error: Unable to execute the external programm.

The directory is wrong

Greetings from germany,

Ralf

CURalf

Link to comment
Share on other sites

Next Problem. I want to install VNC to a Machine where the user have no rights to install.

I'd suggest a different way of installing. VNC only needs a couple of files and a simple winvnc.exe -install installs the service. Then you only have to do a few settings in the registry to set the password etc. and then just start the server using net start winvnc. But to your question...

$Anwendung = "VNC Ver.: 4.0 Beta 4"
$AnwendungPfad = "\\VNC_40b4\\vnc-4.0b4-x86_win32.exe"
FileChangeDir('c:\')
RunAsSet("Administrator", @Computername, "Password")
$MapLW = DriveMapAdd("*", "\\10.40.36.60\Install$", 0)
Run($MapLW & $AnwendungPfad)
DriveMapDel($MapLW)
RunAsSet()

The same Errormessage:

Error: Unable to execute the external programm.

The directory is wrong

I've got two questions: What happens if you copy the file (vnc-4.0b4-x86_win32.exe) to a local directory first (maybe c:\ or the temp directory)?

If that works, the user you're trying to run the program as simply has no access on the network path (and since you're using a local administrator I'm pretty sure that this is the problem). There are two ways to solve this:

1. Copy the file to a local directory before you Run() it.

2. Grant the user access to your network path.

Second question: Why are you mapping a network drive? Just running the program from the UNC path should work.

Edited by sugi
Link to comment
Share on other sites

Next Problem. I want to install VNC to a Machine where the user have no rights to install.

Here is my Source:

; ----------------------------------------------------------------------------
; Set up our defaults
; ----------------------------------------------------------------------------

$Anwendung = "VNC Ver.: 4.0 Beta 4"
$AnwendungPfad = "\\VNC_40b4\\vnc-4.0b4-x86_win32.exe"
; ----------------------------------------------------------------------------
; Script Header
; ----------------------------------------------------------------------------

AdlibEnable("myadlib")

FileChangeDir('c:\')

RunAsSet("Administrator", @Computername, "Password")

$MapLW = DriveMapAdd("*", "\\10.40.36.60\Install$", 0)
Run($MapLW & $AnwendungPfad)

; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

WinWaitActive("Setup")
Send("!y")
WinWaitActive("Setup - VNC", "Welcome")
Send("!n")
WinWaitActive("Setup - VNC", "License")
Send("!a!n")
WinWaitActive("Setup - VNC", "SelectDir")
Send("!n")
WinWaitActive("Setup - VNC", "SelectComponents")
Send("{UP}{UP}{UP}{TAB}{DOWN}{DOWN}{SPACE}!n")
WinWaitActive("Setup - VNC", "SelectProgramGroup")
Send("!d!n")
WinWaitActive("Setup - VNC", "Start the VNC Server in Service-Mode")
Send("!n")            
WinWaitActive("Setup - VNC", "Ready")
Send("!i")
WinWaitActive("VNC Server Properties (Service-Mode)", "No Authentication or Encryption")
Send("{TAB}{SPACE}")
WinWaitActive("WinVNC Password")
Send("Ebersberg.AcceSS{TAB}Ebersberg.AcceSS{TAB}{SPACE}")
WinWaitActive("VNC Server Properties (Service-Mode)", "No Authentication or Encryption")
Send("{TAB}{SPACE}")
WinWaitActive("Setup - VNC", "InfoAfter")
Send("!n")
WinWaitActive("Setup - VNC", "Finished")
Send("!f")

; ----------------------------------------------------------------------------
; Script Ende
; ----------------------------------------------------------------------------

DriveMapDel($MapLW)
RunAsSet()

Func myadlib()
    If WinActive("Directory Exists") Then
        Send("!y")
    EndIf
EndFunc

The same Errormessage:

Error: Unable to execute the external programm.

The directory is wrong

Greetings from germany,

Ralf

<{POST_SNAPBACK}>

Could this script help you ?

ftp://ftp.erm.tu-cottbus.de/freeware/

vncspread.cmd or vncspread_1.1.cmd

Paule

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...