Windows confirm yes no

Windows confirm yes no

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I wrote javascript for confirm popup like below:

var answer = confirm («Are you sure you want to delete this item ?»);

It is showing OK Cancel button popup , but I want to display Yes No buttons on popup insted of OK Cancel buttons.

Appreciate if anyone give proper solution.

Still I could not get proper solution. Please any one help me solve this. need js solution not jquery..

Answers

Keep the Dialog.html and MainPage.html under a single folder and run the mainpage.html from your IE and click the button. you will see the contents of the dialog.html in a modal popup window with Yes No buttons and message.

Click Yes or No button in the modal popup window and it will close the dialog and show an alert based on which button u have clicked in the modal popup

Hope this helps.

All replies

There is not direct option in JavaScript to get Yes/No buttons in a Confirm dialog.

But, we can create a customized dialog box with our own HTML tags, controls and scripts and show it as a confirmation dialog using window.showModalDialog() function

Here is the sample HTML to demonstrate how to create a customized confirmation dialog.

Dialog.HTML (This contains the UI for the confirmation dialog. Message, Yes No buttons etc)

MainPage.HTML (From where the confirmation dialog will be shown. In your case, u can use the script in this html and customize it according to ur needs)

Hope this helps.

See this MSDN Link for more information on how to use and customize the showModalDialog() function

Нужен confirm, но с Yes, No, Cancel

Обычный конфирм дает только OK и Cancel, а мне нужно Yes, No, Cancel.
Кто подскажет?

confirm
при confirm высвечивается сообщение типа «вы согласны»(да/нет) , как сделать чтобы туда еще.

Не работает confirm в IE
Не отрабатывает следующий код в IE:

Confirm кнопка
Почему не выводит подтверждение? должно же вроде, что не так сделал? Удалять то удаляет. echo.

подобие confirm
Подскажите как сделать функцию подобную confirm, само окно с кнопками у меня сделано, как сделать.

К сожалению как на JAVA не знаю. Разобраться, что кто то написал могу, а сам написать не могу. ) Так что приведу пример на VBscript

Хм. Я тут порыл инфу.

В JAVA оказывается можно только через модальные и не модальные окна такое провернуть. Принцип извращён до ужаса — открывается новыя страница, а уже в ней ты делаешь нужные тебе кнопки и т.п

Читайте также:  Командная строка windows как создать текстовый файл

Кстати. Возможно это поможет.

> В JAVA оказывается можно только через модальные и
> не модальные окна такое провернуть. Принцип извращён
> до ужаса — открывается новыя страница, а уже в ней ты делаешь
> нужные тебе кнопки и т.п

Вы поражаете своей дремучестью. не пугайте людей — они тоже могут быть не в курсе.

Во-первых, showModalDialog работает только в MS IE. Хотя с его помощбю действительно можно легко сделать такой запрос — но работать будет только в MS IE.

Во-вторых, причем тут ‘принцип’? В стардартных версиях JavaScript (ECMA) просто не предусмотрены другие диалоги кроме alert(), confirm(), prompt().

Windows confirm yes no

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I have some Windows Server 2008 systems that I’m trying to run a powershell script on to delete some temp files, but I keep getting prompted with «Confirm. Y [Yes] [A] Yes to All. ect» Is there a way to bypass the Confirm?

Tom Martin Email: tmartin@caa.com

Answers

Yes, if you set $confirm to false explicitly, it shouldn’t prompt you to confirm.

get-childitem C:\inetpub\logs\LogFiles -recurse | where-object < $_.LastAccessTime -lt (Get-Date).AddDays(-14) -and $_.LastWriteTime -lt (Get-Date).AddDays(-14) >| remove-item -ErrorAction SilentlyContinue -Confirm:$false

Alternatively, you can try -force parameter as well.

get-childitem C:\inetpub\logs\LogFiles -recurse | where-object < $_.LastAccessTime -lt (Get-Date).AddDays(-14) -and $_.LastWriteTime -lt (Get-Date).AddDays(-14) >| remove-item -ErrorAction SilentlyContinue -Force

PS: Test above changes before trying out in production environment.

All replies

If you are using Remove-Item cmdlet use confirm switch like in below example

Remove-Item .\v.txt -Confirm:$false

I’m using the below command typed directly into PowerShell just for testing purposes. So, I should just be able to add -Confirm:$false to the end and it should not prompt me to Confirm?

Tom Martin Email: tmartin@caa.com

Yes, if you set $confirm to false explicitly, it shouldn’t prompt you to confirm.

get-childitem C:\inetpub\logs\LogFiles -recurse | where-object < $_.LastAccessTime -lt (Get-Date).AddDays(-14) -and $_.LastWriteTime -lt (Get-Date).AddDays(-14) >| remove-item -ErrorAction SilentlyContinue -Confirm:$false

Alternatively, you can try -force parameter as well.

get-childitem C:\inetpub\logs\LogFiles -recurse | where-object < $_.LastAccessTime -lt (Get-Date).AddDays(-14) -and $_.LastWriteTime -lt (Get-Date).AddDays(-14) >| remove-item -ErrorAction SilentlyContinue -Force

PS: Test above changes before trying out in production environment.

I just added -Confirm:$false to the end, but when I run the command locally on the server I’m still getting the following:

Microsoft.Powershell.Core\FileSystem::C:\inetpub\logs\LogFiles\W3SVC1 has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to continue?

[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help

Читайте также:  Приложение нетфликс для windows

I then tried it with –Force, but I received the same Confirm prompt.

Tom Martin Email: tmartin@caa.com

Yes, it should remove anything older than 14 days. files or folders / folders and files.

Tom Martin Email: tmartin@caa.com

Do you mind posting your code here for better clarity? I generally delete all temp files in c:\windows\temp with below code. I face no Confirm prompts.

$TempFiles = Get-ChildItem c:\windows\temp -include *.tmp -recurse

$TempFiles | foreach ($_)

This posting is provided AS IS with no warranties or gurentees,and confers no rights

Yes, it should remove anything older than 14 days. files or folders / folders and files.

Tom Martin Email: tmartin@caa.com

What I mean is the folders that are older than 14 days can still contain other folders and files that have been used recently. The command will try to delete that folder and its files anyway regardless of the files it contains are new or old.

Here’s the code we are using to delete anything older than 14 days. Any suggestions is much appreciated. Thanks

get-childitem C:\inetpub\logs\LogFiles -recurse | where-object < $_.LastAccessTime -lt (Get-Date).AddDays(-14) -and $_.LastWriteTime -lt (Get-Date).AddDays(-14) >| remove-item -ErrorAction SilentlyContinue -Confirm:$false

Tom Martin Email: tmartin@caa.com

This has probably already been answered but I was running into the same problem as you and couldn’t find an answer.

Maybe if I post it here I will be able to find it the next time I run into it. 🙂

I think this will work for you

get-childitem C:\inetpub\logs\LogFiles -include *.log -recurse | where-object < $_.LastAccessTime -lt (Get-Date).AddDays(-14) -and $_.LastWriteTime -lt (Get-Date).AddDays(-14) >| remove-item -ErrorAction SilentlyContinue -Confirm:$false

replace *.log without ever wildcard you need.

I was executing this

and getting the same as you

Microsoft.Powershell.Core\FileSystem::C:\logs\blah has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to continue?

I replaced it with

get-childitem -Recurse c:\logs\ -include *log*| where <$_.LastWriteTime -le $now.AddDays(-30)>| del -whatif

and like magic no more prompts.

I’m having this issue with the «Confirm» dialog continuously popping up, no matter what combination of parameters I try. I’ve been reading this blog and tried using multiple combinations, to no avail.

Here is my command: Get-ChildItem ‘c:\builds\testing’ -recurse | where <$_.LastWriteTime -le (Get-Date).AddDays(0)>| del

-ErrorAction SilentlyContinue -Confirm:$false

If any one can help it would be greatly appreciated.

NOTE: I also set the $ConfirmPreference = «None»

Thanks In Advance!

I was able to solve this probably, with some internal help.

Here is my command I used to suppress the confirm dialog that I was getting:

Get-ChildItem c:\builds\testing -recurse | where-object <$_.LastWriteTime -le (Get-Date).AddDays(0)>| remove-item -force

-recurse

I hope this will be of some help to someone else that is having the same problem.

Читайте также:  Creating new folder shortcut windows

Does anybody know how can I add exclusions by folder(and all its contents) to this script ?

I have 3-4 folders and their content which I would like to keep!

You can use the existing where clause to exclude the folders. If you still have questions, you’re probably better off starting a new thread, as this one is old and already marked as answered.

Have been there have strugled with that . but -comfirm:0 has worked for me . also using -verbose but that should be a different matter. you could try $false= 0 , in Your site constant and variable section.

Stumbled on this, and the voted answer didnt get me anywhere. one of the below replies got me closer, but still no cookie. trying a few things based on the errors i was getting, and I stumbled onto the command to remove an item with out the prompt that i verified works in my Powershell is:

remove-item c:\drop\ -recurse

«c:\drop» is the folder and child objects you want removed without having to confirm.

I am using in this format:

You must use -Recurse .

apparently, you just need to add -recurse

Remove-Item -path «C:\somefolder\*» -recurse

All of the above solutions failed for me when I was create a directory, which meant that I was prompted to OK every single directory that my script created — which was a lot. What worked for me was to apped | Out-null in order to pipe the results to Out-Null

Note that $Directory is a string with the full path to the directory you want to create. Hope this saves somebody some time 😛

is not working with ErrorAction SilentlyContinue -Force or -ErrorAction SilentlyContinue -Confirm:$false

here is my sample code.

$StartFolder = $args[0] #»c:\temp\deleteTest»
$mheExlude = $args[2] #’*ExcludeFolder*’
[decimal]$olderthen = $args[1] #’10’
Get-ChildItem -Path $StartFolder -Recurse | where <$_.LastWriteTime -le $(get-date).AddDays(-[decimal]-$olderthen) -and $_.FullName -notlike $mheExlude >| Remove-Item -ErrorAction SilentlyContinue -Force -WhatIf

here is how i call it.

Powershell.exe -executionpolicy remotesigned -File c:\tools\PS\DeleteFilesolderthen-V.ps1 «c:\temp\deleteTest\ Images» «90» «* ExcludeFolder *»

Confirm
The item at Microsoft.PowerShell.Core\FileSystem:: c:\temp\deleteTest\ Image \SubFolder has children and the Recurse parameter was
not specified. If you continue, all children will be removed with the item. Are you sure you want to continue?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is «Y»):

is not respecting the confirmation

not for lack of tring.

is not working with ErrorAction SilentlyContinue -Force or -ErrorAction SilentlyContinue -Confirm:$false

here is my sample code.

$StartFolder = $args[0] #»c:\temp\deleteTest»
$mheExlude = $args[2] #’*ExcludeFolder*’
[decimal]$olderthen = $args[1] #’10’
Get-ChildItem -Path $StartFolder -Recurse | where <$_.LastWriteTime -le $(get-date).AddDays(-[decimal]-$olderthen) -and $_.FullName -notlike $mheExlude >| Remove-Item -ErrorAction SilentlyContinue -Force -WhatIf

Оцените статью