Jump to content
Sign in to follow this  
Beekman

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

Recommended Posts

Beekman

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.

 

Share this post


Link to post
Share on other sites
FireFox

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Beekman

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)

Share this post


Link to post
Share on other sites
FireFox

huh?

I don't see my script in yours.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
FireFox

Or simply:

#RequireAdmin

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Beekman

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?

Share this post


Link to post
Share on other sites
BrewManNH

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

Share this post


Link to post
Share on other sites
Beekman

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

Share this post


Link to post
Share on other sites
BrewManNH

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

Share this post


Link to post
Share on other sites
Beekman

Hello,

I have tried this line but nothing happens. The file is not being copied.

RunAsWait("admin", "domain", "password", "", '"' & @ComSpec & '" /c copy "c:\temp\clupgrade\mc.dll" "c:\apps\ibm\lotus\notes"', @SystemDir)

Share this post


Link to post
Share on other sites
BrewManNH

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

Share this post


Link to post
Share on other sites
Beekman

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

Share this post


Link to post
Share on other sites
Unc3nZureD

RunAsWait("admin", "domain", "password", "", @ComSpec &  '/c copy "c:\temp\clupgrade\mc.dll" "c:\apps\ibm\lotus\notes\mc.dll"', @SystemDir)

I think this one should work.

Edited by Unc3nZureD
  • Like 1

Share this post


Link to post
Share on other sites
Beekman
RunAsWait("admin", "domain", "password", "", @ComSpec &  '/c copy "c:\temp\clupgrade\mc.dll" "c:\apps\ibm\lotus\notes\mc.dll"', @SystemDir)

I think this one should work.

No sorry.

If I use the cmd the copy command is working ok, only when I am using it in combination with Autoit nothing happens.

Edited by Beekman

Share this post


Link to post
Share on other sites
Jos

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Unc3nZureD

I forgot to put a SPACE before the /C. Try this one:

RunAsWait("admin", "domain", "password", "", @ComSpec &  ' /C copy "c:\temp\clupgrade\mc.dll" "c:\apps\ibm\lotus\notes\mc.dll"', @SystemDir)

Lol, Jos was faster by about 2sec xD

Edited by Unc3nZureD

Share this post


Link to post
Share on other sites
Beekman

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

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  

×