WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: geauga on May 01, 2019, 07:31:49 AM

Title: Copy Internet Shortcut to Public Desktop
Post by: geauga on May 01, 2019, 07:31:49 AM
No matter what logic I try I cannot seem to copy an Internet shortcut to the public desktop.  I know that it requires privileges to load a file so that implies that I need to use RunWithLogon.  I initially tried using a DOS command: RunWithLogon ("Copy.exe","C:\Data\GoToAssist.url C:\Users\Public\Desktop\GoToAssist.url",  "", "", @NORMAL, @WAIT, runas_user, runas_domain, runas_pass,1)

When that failed I tried using the RunWithLogon and a Winbatch command.  Any suggestions on how to do this?

RunWithLogon (FileCopy("C:\Data\GoToAssist.url", "C:\Users\Public\Desktop\GoToAssist.url",@FALSE),  "", "", @NORMAL, @WAIT, runas_user, runas_domain, runas_pass,1)
RunWithLogon (IniWritePvt ("InternetShortcut", "URL", "https://broker.gotoassist.com/h/test", "C:\Users\Public\Desktop\GoToAssist.url"),  "", "", @NORMAL, @WAIT, runas_user, runas_domain, runas_pass,1)



Title: Re: Copy Internet Shortcut to Public Desktop
Post by: td on May 01, 2019, 08:16:16 AM
In the future please take the time to indicate more precisely what you mean by "failed".  You need to indicate whether or not you received an error message and what that error message was if you did receive one.  Secondly, you need to indicate which version of Windows you are running your script on.

You can't use RunWithLogon by itself to start an elevated admin process from a lower integrity process on a UAC enable system.  This Tech Database article references a couple of workarounds:

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UAC+RunWithLogon~and~UAC.txt (http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UAC+RunWithLogon~and~UAC.txt)

Also, you are not using RunWithLogon correctly in several of your examples.   The Consolidated WIL Help file documents that the first parameter is

"(s) program-name: the name of the desired .EXE, .COM, .PIF, .BAT, .CMD file or a data file."

and not Wil function calls.