skate_cadette Posted November 2, 2018 Posted November 2, 2018 expandcollapse popup##; Prompt the user to run the script - use a Yes/No prompt with the flag parameter set at 4 (see the help file for more details) Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "Update", "This script will update the program on a domain-connected PC. Do you want to run it?") ##; Check the user's answer to the prompt (see the help file for MsgBox return values) ##; If "No" was clicked (7) then exit the script If $iAnswer = 7 Then MsgBox($MB_SYSTEMMODAL, "Update", "OK.") Exit EndIf ##; Loop around until the user enters a computer number or clicks cancel. Local $iLoop = 1, $pcID While $iLoop = 1 $pcID = InputBox("Update", "Please enter a valid PC ID and click OK") If @error = 1 Then ##; Print the message MsgBox($MB_SYSTEMMODAL, "Update", "OK") $iLoop = 0 ; Exit the loop Else ##; They clicked OK, but did they enter a PC ID? If $pcID = "" Then ##; The user did not enter a PC ID MsgBox($MB_SYSTEMMODAL, "Error", "Please enter a PC ID") Else $iLoop = 0 ; Exit the loop EndIf EndIf WEnd $sLastError = _WinAPI_GetLastErrorMessage() $UserID = "user.id" ##;Hard-coded user ID $Password = "password" ##;Hard-coded password ;$UserID = InputBox ("User", "Enter Administrative Account", "", "") ##;USE THESE LINES TO INSTEAD PROMPT THE USER FOR CREDENTIALS ;$Password = InputBox ("Password", "Enter Password","", "X") ##;USE THESE LINES TO INSTEAD PROMPT THE USER FOR CREDENTIALS $Domain = "@ComputerName" $Source = "\\myserver\TEST.txt" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Source = ' & $Source & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $Destination = "\\ORG-" & $pcID & "\c$\TEMP" ##;TEMP directory for testing, requiring no admin permissions for writing ##;$Destination = "\\ORG-" & $pcID & "\c$\Program Files (x86)\myprogram\" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Destination = ' & $Destination & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console If Not RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & ' /c '& 'copy "& $Source" "& $Destination" ', @SW_HIDE) Then Exit MsgBox($MB_ICONERROR, "ERROR!", "Error copying files. " & $sLastError) ##;FileCopy($Source, $Destination) Hello, I am attempting to use the code above to copy a file from a network location to a folder on a specified computer. _WinAPI_GetLastErrorMessage is returning a value of "Operation completed successfully" in the message box from the second last line, but the file is not copied. Can I please have some assistance with: A ) Why is my error message incorrect? B ) Why is my file not being copied? Much appreciation to anyone who can help. Thank you. Mel
dmob Posted November 2, 2018 Posted November 2, 2018 At first glance, your quotes don't look right... And remove all the ##, they generate too many errors....
Nine Posted November 2, 2018 Posted November 2, 2018 Agree with dmob, create a new .au3 with the first line being your runaswait (totally hard coded), and show @error after that, like : $a = runaswait (....) msgbox (0, "test", $a & "/" & @error) Make your runaswait work, then gradually you can add the UI after “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
skate_cadette Posted November 7, 2018 Author Posted November 7, 2018 Thanks for the input so far. On 11/2/2018 at 9:23 PM, dmob said: At first glance, your quotes don't look right... And remove all the ##, they generate too many errors.... I added the ## in the post box on this forum - without it the code did not recognise the text after ; as comments. The code that I am attempting to run does not have the ## Can I ask what you mean by "your quotes don't look right"? On 11/3/2018 at 12:01 AM, Nine said: Agree with dmob, create a new .au3 with the first line being your runaswait (totally hard coded), and show @error after that, like : $a = runaswait (....) msgbox (0, "test", $a & "/" & @error) Make your runaswait work, then gradually you can add the UI after Thank you. I tried this. The msgbox returns text of "0/1", which is not exactly a helpful error message I have debug lines in my code that confirm the variables that are used for $source and $destination. I attempted to run a simple "copy" from the command line using these variables, which is working so I can say that the destination and source are correct. Does anyone have any ideas on how I can error check or debug this code (even just the runaswait line) so that I can see exactly what the error is?
Nine Posted November 7, 2018 Posted November 7, 2018 Can I ask what you mean by "your quotes don't look right"? Your single and double quotes in the runaswait doesn't seem well balanced. This is why I was asking you to simplify your code in order to make the runaswait line worked first. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
dmob Posted November 7, 2018 Posted November 7, 2018 (edited) 9 hours ago, skate_cadette said: Can I ask what you mean by "your quotes don't look right"? Try this (untested): If Not RunAsWait($UserID, $Domain, $Password, 0, @ComSpec & ' /c ' & 'copy "' & $Source & '" "' & $Destination & '"', @SW_HIDE) Then P.S. If you use Scite, the syntax highlighting makes it easier to spot errors like unmatched quotes. Edited November 7, 2018 by dmob
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now