Jump to content

simple copy 1 file from A to B will admin rights are needed.


Recommended Posts

Hello guys,

Can someone help me with the following script.

 

RunAsWait("admin", "domein", "password", "", '"' & @ComSpec & '" /c ' & FileCopy ("c:tempclupgrademc.dll", "C:AppsIBMLotusNotes"), @SystemDir)

this does.nt seems to work.

 

Link to comment
Share on other sites

Hi,

It does not work as you think it does.

 

I don't know how to explain it to you (with the mistake you did), so try to understand with this:

; If the script is run without admin rights.
If IsAdmin() = 0 Then
    ; If the script is compiled
    ; Re-execute the script in elevated rights.
    If @Compiled Then
        ShellExecute(@ScriptFullPath, "", @WorkingDir, "runas")
    Else
        ShellExecute(@AutoItExe, '/AutoIt3ExecuteScript "' & @ScriptFullPath & '"', @WorkingDir, "runas")
    EndIf
    Exit
Else
    ; Do the copy
    FileCopy ("c:\temp\clupgrade\mc.dll", "C:\Apps\IBM\Lotus\Notes")
EndIf
Br, FireFox. Edited by FireFox
Link to comment
Share on other sites

Thx Firefox,

But the file copy is part of a install script.

And you need admin right to place the file in the directory.

I doesn't seems to get it work properly.

If ProcessExists("msiexec.exe") Then
    MsgBox(0, "Information", "Lotus Notes wordt niet geupgrade omdat er op dit moment al een ander programma wordt geinstalleerd")
    Exit 
EndIf
$cmd1 = "regedit /s c:\temp\CLupgrade\UACuit.reg"
RunAsWait("admin", "domein", "password", "", '"' & @ComSpec & '" /c ' & $cmd1, @SystemDir)
$cmd2 = 'c:\temp\clupgrade\install\setup /s /v"SETMULTIUSER=1 PROGDIR=C:\Apps\IBM\Lotus\Notes /qb!- TRANSFORMS=YGAO95CMDX.mst"'
$cmd3 = 'c:\temp\clupgrade\elevate c:\temp\clupgrade\fixpack3\setup /s /v"/qb!+"'
Local $size1 = FileGetSize("c:\temp\clupgrade\install\setup.exe")
Local $size2 = FileGetSize("c:\temp\clupgrade\fixpack3\setup.exe")
If $size1 = 173408 AND $size2 = 7219000 Then
    Local $pid = RunAsWait("admin", "domein", "password", "", '"' & @ComSpec & '" /c ' & $cmd2, @SystemDir)
    ProcessWaitClose($pid)
    RunAsWait("admin", "domein", "password", "", '"' & @ComSpec & '" /c ' & $cmd3, @SystemDir)
 EndIf

Here comes the file copy

$cmd5 = "regedit /s c:\temp\clupgrade\UACaan.reg"
RunAsWait("admin", "domein", "password", "", '"' & @ComSpec & '" /c ' & $cmd5, @SystemDir)
Link to comment
Share on other sites

If I use #requireAdmin the customer is getting a prompt to fill in the admin credentials.

So the script has to run without filling in anyting by the customer.

Thats why I use so many times the RunAsWait("admin", "domein", "password", " command.

But for the filecopy I am not getting it to work. Do you have an other solution?

Link to comment
Share on other sites

Where is the file copy part of the code, all I see in your RunAs command variables is a lot of RegEdit commands, no copies?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Where is the file copy part of the code, all I see in your RunAs command variables is a lot of RegEdit commands, no copies?

Hello, Thats the line in my first topic(RunAsWait("admin", "domein", "password", "", '"' & @ComSpec & '" /c ' & FileCopy ("c:tempclupgrademc.dll", "C:AppsIBMLotusNotes"), @SystemDir))

But I removed it from the script because it doesn't work.

The file copy should take place above the  $cmd5 line

Link to comment
Share on other sites

I was looking for it in the code you posted, because that's where one would expect to find the lines that aren't working. Trying to guess where you put that line in your code isn't good enough, you should have included it in your posted code with a comment.

From looking at what you wrote there though, it's never going to work. FileCopy is an internal AutoIt function, ComSpec has no idea what to do with it. Use Copy "source" "destination" when using ComSpec.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Your quotes are wrong in that line, if you're using double quotes around the file paths you have to either double them or use single quotes around the whole string.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Your quotes are wrong in that line, if you're using double quotes around the file paths you have to either double them or use single quotes around the whole string.

Thx, but I do not fully understand what you are saying.

can you write the string

Link to comment
Share on other sites

  • Developers

there is a space missing in front of the '/C which would make it error out.

Try it with a /K to keep the cmd window open while testing:

' /k copy "c:\temp\clupgrade\mc.dll" "c:\apps\ibm\lotus\notes\mc.dll"'

Jos :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thx again,

There was already a space between the ' /C and i tried it with the /k.

I am getting access denied 0 files copied.

Why is this happening because when i use the same credentials, copieng the file by hand, it is copieng the file good.

Also the rest of the script is using these credentials and are working fine.

I tested some more. It looks like the open command prompt is not opened with the admin credentials.

Because with the /k de command prompt stays open en when i want to do een copy by hand I still getting a access denied.

Edited by Beekman
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...