muncherw Posted November 5, 2008 Share Posted November 5, 2008 I have a user that needs a file deleted but can't remove it himself due to a rights issue. Our SCCM client isn't installed on his machine so I can't just do it myself without physically going there, which I won't be able to do for some time. I'd like to send him a compiled script that will delete it. FileDelete doesn't have any arguments for username and password. I've looked at RunAs but I don't know if that's the answer for what I want either. Would someone point me to the correct function or guide me in using what I've mentioned? $userName = "mwoods" $password = "password" ;something in here to give FileDelete permission to run based on my username and password FileDelete("c:\Novell\Groupwise\gwxl97.xla") FileDelete("c:\Program Files\Microsoft Office\Office10\XLStart\gwxl97.xla") FileDelete("c:\Program Files\Microsoft Office\Office12\XLStart\gwxl97.xla") Thanks. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
monoceres Posted November 5, 2008 Share Posted November 5, 2008 Hi! This is a way: Func DeleteAs($username, $domain, $password,$logon_flags, $filename) RunAs($username, $domain, $password, $logon_flags, @AutoItExe & ' /AutoIt3ExecuteLine "FileDelete(''' & $filename & ''')"') EndFunc ;==>DeleteAs Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
muncherw Posted November 5, 2008 Author Share Posted November 5, 2008 What does /AutoIt3ExecuteLine do? So should this work? $username = "mwoods" $domain = '@COMPUTER' $password = "password" $filePath = "c:\Novell\Groupwise\gwxl97.xla" RunAs($username, $domain, $password, 0, @AutoItExe & ' /AutoIt3ExecuteLine "FileDelete($filePath)"') Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
monoceres Posted November 5, 2008 Share Posted November 5, 2008 What does /AutoIt3ExecuteLine do? So should this work? $username = "mwoods" $domain = '@COMPUTER' $password = "password" $filePath = "c:\Novell\Groupwise\gwxl97.xla" RunAs($username, $domain, $password, 0, @AutoItExe & ' /AutoIt3ExecuteLine "FileDelete($filePath)"') /AutoIt3ExecuteLine allows you to run one line of autoit code directly from the command line. I don't know if your code works (quotes & command lines are tricky) but I know my code does. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
spudw2k Posted November 5, 2008 Share Posted November 5, 2008 Interesting. So any compiled AutoIt script can use the /AutoIt3ExecuteLine flag to execute code? Seems to be the case. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
muncherw Posted November 5, 2008 Author Share Posted November 5, 2008 /AutoIt3ExecuteLine allows you to run one line of autoit code directly from the command line. I don't know if your code works (quotes & command lines are tricky) but I know my code does.Mine doesn't work. And I'm on my own machine with full rights to everything so I don't even need to run it as admin. I think this means I'm not doing the delete properly. Basically I just tried plugging my stuff into your line but somethign is amiss and I'm not figuring out how to troubleshoot it. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
muncherw Posted November 5, 2008 Author Share Posted November 5, 2008 Interesting. So any compiled AutoIt script can use the /AutoIt3ExecuteLine flag to execute code?Seems to be the case.Yeah, that's what I was wondering because this isn't going to be run on a machine that has AutoIt installed. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
Developers Jos Posted November 5, 2008 Developers Share Posted November 5, 2008 Mine doesn't work. And I'm on my own machine with full rights to everything so I don't even need to run it as admin. I think this means I'm not doing the delete properly. Basically I just tried plugging my stuff into your line but somethign is amiss and I'm not figuring out how to troubleshoot it.It is clear that your code will not work because $filepath is plugged in in stead of the filename, that is why you need to use the original posted script and change it to use the proper variable.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
muncherw Posted November 5, 2008 Author Share Posted November 5, 2008 (edited) It is clear that your code will not work because $filepath is plugged in in stead of the filename, that is why you need to use the original posted script and change it to use the proper variable.JosAaaaah. Those quotes were confusing me so I thought that variable would work.Okay, wait, you are saying I can use a variable. So I guess I don't understand. I think I'm not seeing something you guys are saying should be right in front of my face. I worked the election last night after working my regular shift- my brain is a few throwing stars short of, well, of whatever Kid Niki keeps his throwing stars in. Edited November 5, 2008 by muncherw Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 5, 2008 Share Posted November 5, 2008 If you want to use a variable, it has to be outside the string, otherwise you end up with the literal string name of the variable. Link to comment Share on other sites More sharing options...
muncherw Posted November 5, 2008 Author Share Posted November 5, 2008 This doesn't work...but is it closer? RunAs($username, $domain, $password, 0, @AutoItExe & ' /AutoIt3ExecuteLine "FileDelete("c:\Documents and Settings\MWoods\desktop\index.html")"') I'm befuddled by the quotes. At least I t hink it's the quotes that are messing me up. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
spudw2k Posted November 5, 2008 Share Posted November 5, 2008 (edited) This doesn't work...but is it closer? RunAs($username, $domain, $password, 0, @AutoItExe & ' /AutoIt3ExecuteLine "FileDelete("c:\Documents and Settings\MWoods\desktop\index.html")"') I'm befuddled by the quotes. At least I t hink it's the quotes that are messing me up.It's messy, but sometimes I'll use the Chr() func and keycode 34 to write a " in a string. RunAs($username, $domain, $password, 0, @AutoItExe & ' /AutoIt3ExecuteLine "FileDelete(' & chr(34) & 'c:\Documents and Settings\MWoods\desktop\index.html' & chr(34) & ')"') Edited November 5, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 5, 2008 Share Posted November 5, 2008 Why can't you just use the function that monoceres provided back on post 2? Link to comment Share on other sites More sharing options...
spudw2k Posted November 6, 2008 Share Posted November 6, 2008 True, simply using a var with monoceres' example will work just fine. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
muncherw Posted November 6, 2008 Author Share Posted November 6, 2008 (edited) Why can't you just use the function that monoceres provided back on post 2? That's what I'm trying to do. I *want* to use his function. I'm not understanding it. $username = "mwoods" $domain = '@COMPUTER' $password = "password" $logon_flags = 0 $filename = "C:\Documents and Settings\mwoods\Desktop\index.html" DeleteAs($username, $domain, $password, $logon_flags, $filename) Func DeleteAs($username, $domain, $password, $logon_flags, $filename) RunAs($username, $domain, $password, $logon_flags, @AutoItExe & ' /AutoIt3ExecuteLine "FileDelete(''' & $filename & ''')"') EndFunc ;==>DeleteAs I thought I was just plugging in my stuff for his but I guess I was modifying more than I thought. Edited November 6, 2008 by muncherw Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
grtech Posted August 10, 2012 Share Posted August 10, 2012 (edited) Try this $Username = "mwoods" $domain = @ComputerName $Password = "password" $logon_flags = 0 $filename = "C:Documents and SettingsmwoodsDesktopindex.html" DeleteAs($username, $domain, $password, $logon_flags, $filename) Func DeleteAs($username, $domain, $password, $logon_flags, $filename) RunAs($username, $domain, $password, $logon_flags, @AutoItExe & ' /AutoIt3ExecuteLine "FileDelete(''' & $filename & ''')"') EndFunc ;==>DeleteAs Edited August 10, 2012 by grtech Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 10, 2012 Moderators Share Posted August 10, 2012 grtech,Why did you post exactly the same code as monoceres had already posted 4 years ago? Please do not necro-post like this. M23P.S. The question is rhetorical - please do not respond. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
grtech Posted August 13, 2012 Share Posted August 13, 2012 Appologies if it looks the same put it is not exactly the same, there is a slight mistake and i corrected, as i have got it working, i thought that i would update the post so that everyone who did a search on it could also get the code to work. Thanks GRTech Link to comment Share on other sites More sharing options...
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