Jump to content

Filedelete issues because of quotes


Go to solution Solved by MikahS,

Recommended Posts

Posted

Hi,

I'm creating a gui that will clear the contents of a specific folder remotely.  I'm having trouble I believe because filedelete requires quotes around the path, but the way I've coded it (string?) also requires the quotes.  How can I make this work?  I'm just starting to script, so sorry if I'm not saying it correctly

;~ This works
FileDelete ("\\is1127000\c$\Windows\System32\spool\PRINTERS\")

;~ Doens't work
FileDelete (""\\" & $computerName & "\c$\Windows\System32\spool\PRINTERS\"")

;~ Also doens't work
FileDelete ("\\" & $computerName & "\c$\Windows\System32\spool\PRINTERS\")

;~ Also doesn't work
$Read= GUICtrlRead ($Input1)
$start="("
$close=")

$computerName = GUICtrlRead($Input1)
FileDelete $start & "\\" & $computerName & "\c$\Windows\System32\spool\PRINTERS\" & $close
  • Solution
Posted (edited)

does this work for you?

Local $computerName, $fDel

$computerName = GUICtrlRead($Input1) ; must declare the variable and set it if your going to use it first

$fDel = FileDelete ("\\is1127000\c$\Windows\System32\spool\PRINTERS\")
If $fDel = 0 Then
    MsgBox(0, "", "first File delete didn't work because it didn't exist or didn't delete the file")
EndIf

$fDel = FileDelete ("\\" & $computerName & "\c$\Windows\System32\spool\PRINTERS\")
If $fDel = 0 Then
    MsgBox(0, "", "second File delete didn't work because it didn't exist or didn't delete the file")
EndIf

$fDel = FileDelete ("\\" & $computerName & "\c$\Windows\System32\spool\PRINTERS\")
If $fDel = 0 Then
    MsgBox(0, "", "third File delete didn't work because it didn't exist or didn't delete the file")
EndIf

$fDel = FileDelete ( "\\" & $computerName & "\c$\Windows\System32\spool\PRINTERS\" )
If $fDel = 0 Then
    MsgBox(0, "", "fourth File delete didn't work because it didn't exist or didn't delete the file")
EndIf

EDIT: Also, welcome to the AutoIt forum woody619 ;)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

That works!  Looks like I tried that, but must've messed up something somewhere else that day.  Thanks for your help

;~ Also doens't work
FileDelete ("\\" & $computerName & "\c$\Windows\System32\spool\PRINTERS\")
Posted

 

That works!  Looks like I tried that, but must've messed up something somewhere else that day.  Thanks for your help

;~ Also doens't work
FileDelete ("\\" & $computerName & "\c$\Windows\System32\spool\PRINTERS\")

 

Glad to help :)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...