I am trying to delete a file from the public desktop if it exists and this requires elevated privileges. This leads me to use RunWithLogon. I have tried various iterations all to no avail. Any syntax recommendations? I have tried pass the file to delete as a parameter and concatenated to the DEL command.
delcmd = StrCat("DEL", " C:\Users\Public\Desktop\Home Health - Prod.lnk")
RunWithLogon ( delcmd, "", "", @NORMAL, @WAIT, runas_user, runas_domain, runas_pass,1)
Assuming you are working in a UAC environment and you truly mean 'elevate' then you can't use RunWithLogon to elevate a process. Please see the following Tech DB article:
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)
Once you get that sorted out, you might want to consider just using the 'FileDelete' function instead of fooling around with the 'del' command shell command.
This is not a UAC issue it is really just file security issue where the users only have READ and EXECUTE access to the file that I need to delete. I would much rather use FileDelete then spawning off a DOS command. I will try your suggestion of the "bootstrapper" process.
If you are working in a UAC environment and you need to give a standard user full admin privileges, it is a UAC issue because running a process with an admin token does not necessarily mean the process has full admin privileges.