WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: geauga on December 08, 2016, 09:11:30 AM

Title: RunWithLogon & DOS Commands
Post by: geauga on December 08, 2016, 09:11:30 AM
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)
Title: Re: RunWithLogon & DOS Commands
Post by: td on December 08, 2016, 10:31:36 AM
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.
Title: Re: RunWithLogon & DOS Commands
Post by: geauga on December 08, 2016, 10:47:12 AM
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.
Title: Re: RunWithLogon & DOS Commands
Post by: td on December 08, 2016, 11:08:19 AM
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.