Windows Batch

12K

Solutions

11K

Contributors

Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hello experts,
I have the txt attached.
I am trying to extract value between label for the various lines:
eg:

<item id="l_BevelTextGallery" imageMso="BevelTextGallery" label="BevelTextGallery"/>
<item id="l__3DMaterialMixed" imageMso="_3DMaterialMixed" label="_3DMaterialMixed"/>

The result should be:
BrevelTextGallery
_3DMaterialMixed

I suppose that I can do that with findstr.
How should I set up the command?
Thank you very much for your help.
icons-labels.txt
1
Windows Server 2008

I have the following on Windows Server 2008 and it works fine via regular FTP:

.bat file:
ftp -n -i -s:upload.txt

which runs upload.txt, which has the following:

open 213.22.11.234
user my_user
hsfer3425er
binary
put C:\Apps\Customers.csv
put C:\Apps\Quotes.csv
bye

What I need to do is make this SFTP instead of regular FTP. How to do that?
0
Hello Experts
I need a batch file or script to add map driver for network location with letter x for example and ask for credential
and another batch or script to remove that mapped drive and credential for that network address
The scenario information
server IP: 192.168.1.254
shared folder on that IP: Home
Domain name: Private.local
1
Hello experts,
I am looking for the fastest way in windows batch to find locations of files with specific string recursively based on a reported folder and export result as txt file.
Thank you very much.
0
Hello Experts
I need script or what ever tools that allowing me to suspend or stop SQL service at the weekend, even if some one restart the server, until a revers or resume script runing.
The management won't allow users to access applications out of work time
0
Hello Experts
I have citrix Xenapp 6.5 R2  in my company, for some reason management need users to open application from citrix web page instead of citrix receiver application.
as i know when users click on application on citrix web, launch.ica downloaded automatically and then users need to open that ICA file to lunch that application, then this ICA file deleted automatically when user end that application.
Unfortunately  that ICA file not deleted automatically until user exit the citrix receiver from task bar.
what i need is forcing  citrix to delete these ICA files immediately when users end these sessions
0
I have a batch file that stops after running an executable.  Here are the contents:

taskkill /F /IM "updox central.exe"
timeout 15
"C:\Program Files (x86)\Updox\Updox Central\Updox Central.exe"
timeout 15
taskkill /F /IM cmd.exe
0
Hello experts,
I have the following command which allows me to remove files based on date:
ForFiles /p "C:\FolderName" /s /d -30 /c "cmd /c del @file"

Open in new window

.
I want to have the version without drill down mode.
Thank you in advance for your help.
1
Hello experts,

I am looking for the fast and smart way to backup files and folder through robocopy with drill down mode from a source directory to a target directory which include date stamp folder.

The variable to get datestamp folder is the following:

REM Get current date/time
set LocalDateTime=
for /f "tokens=* skip=1" %%A in ('wmic os get LocalDateTime') do (
    if not defined LocalDateTime (
        set LocalDateTime=%%A
    )
)

REM Format current date/time as YYYYMMDD_hhmmdd
set VAR_MYDATE=%LocalDateTime:~0,8%_%LocalDateTime:~8,6%

Open in new window



The idea is to be able to launch the script through cmd withtout saving .bat file. If not possible I will save as .bat file.

Thank you in advance for your help.
0
About a month ago my scheduled batch backup using xcopy began to fail.  I posted a question about the issue on EE and eventually scrapped the xcopy  with a new backup using Robocopy

Old xcopy Backup
xcopy "I:\My Documents\*.*" "K:\Mike\" /s /y /f

Open in new window

Robocopy backup
set LogFile=I:\My Documents\copylog.txt
RoboCopy "I:\My Documents" "K:\RoboCopy" /E /TEE /LOG+:"RoboCopyLog.txt"

The xcopy retained files on the destination that had been removed from the source and I set up the new Robcopy to do the same.

Now the xcopy backup contains files that aren’t in the new Robocopy backup.  These would be files that had been removed from the source drive over time.

The source directory for both backups is I:\My Documents.  There are many subdirectories under this main directory.
I would like to set up a onetime Robocopy that will copy from K:\Mike to K:\Robocopy.  However, the only files (and possibly directories I want to copy are the ones that don’t exist in K:\Robocopy.

What parameters do I use on the onetime RoboCopy to accomplish this?
RoboCopy "K:\Mike" "K:\RoboCopy"  /?????
0
Need assistance with using ROBOCOPY on Windows Server 2016 Datacenter. In the past, prior to Server 2003, the /mov or /move switch would simply move the data, including files and folders inside a directory to another directory specified in the command. However, now it deletes the source directory after executing the move, see the command below:

ROBOCOPY "C:\(path)\Upload" "F:\(path)\Upload_Completed" /MOV /E /NP /LOG+:"C:\Scripts\movelog.LOG"

The "Upload" directory is deleted once the command completes. I DO NOT want the "Upload" directory deleted. I ONLY want to move the files and folders to the "Upload_Completed" directory. Is there a better way to achieve this goal. Please advise. Thank you.
0
hello,
I want to create a script that check files on folder and sub folders that is old than 5 days then delete them.
thanks.
0
need help with psexec

1. I have a folder with 10 files including a script file setup.bat on the c:\package folder.

2. I have a list on computers on which I want to copy the c:\package folder on the c:\list.txt

3. I want to copy c:\package from my local computer to c:\package on all computers in the c:\list.txt

the command I tried is similar to this (psexec @C:\TEMP\list.csv -u MyDomain\Username -c c:\file.exe)

no matter what I try the error is the specified application is not in the path.


4. then I need to run this setup.bat on all computers in the c:\list.txt

running the setup.bat can be another command as I do not know how long will it take to copy the folder. it is 180 MB.

I have to do this on 500 computers. I am planning to do it in 25 batches provided the scripts work. help appreciated
0
I have a script that clears the downloads folder (which is redirected).
First It deletes existing Pending_deletion folder, then recreates new Pending_deletion folder, then moves Downloads content to the Pending_Deletion.
Volume Structure:
\\Server1\Downloads\user1\Downloads\Pending_deletion
\\Server1\Downloads\user2\Downloads\Pending_deletion
\\Server1\Downloads\user3\Downloads\Pending_deletion

Problem is the script gives permission of the user account running the script. I need to give Full Control to the actual user of that Downloads folder
What code is need in the script to give the user Full Control to the Pending_deletion folder?
---------------------------------------
Set root=\\Server1\Downloads

For /F %%u in ('dir /a:d /b \\Server1\Downloads\') do (
   IF Exist "%root%\%%u\Downloads\." (
      RD /S /Q "%root%\%%u\Downloads\Pending_deletion"
      MD %root%\%%u\Downloads\Pending_deletion
      for /D %%d in ("%root%\%%u\Downloads\*") do (
            move "%%~d" "%root%\%%u\Downloads\Pending_deletion\"
      )      
      move "%root%\%%u\Downloads\*" "%root%\%%u\Downloads\Pending_deletion\"
  )
)
------------------------------------------
0
Hello,

I am create a package in our software deployment tool.  Basically, the package runs an executable to install an application.  I include a custom script to copy files from a centralize location to a folder under the %userprofile% of the target computer.  However, the copy doesnt happen.  I think this is because the %userprofile% from remote is not working.  

I am just using XCOPY in that script.

Anyone has any suggestion?

Many thanks.
1
I need to verify if a drive exist prior opening a windows apps.  I was thinking maybe using command prompt batch or powershell batch file to do this.  I want to have that code verify if drive J exist and if so, execute the windows apps.  If doesn't exist, then exit the routing messaging "Drive has to exsist".  How can I do this?
1
How do I set the default browser via batch or powershell script in Windows 10? I need to override Microsoft Edge as the default browser and replace it with Internet Explorer for a customer. What would be the best practice for going about this?
0
What is the best method for setting a desktop background of ANOTHER USER or ALL USERS through script on a non-networked (WorkGroup) Windows 10 workstation? I have the ability to use powershell or command prompt for script execution. The image is a .jpg, and all methods that I found online that involve changing the registry require a .bmp image. I do not have the ability to change the background as agreements forbid modification of the image in any way.
0
We are using a software which is time logging, so staff logs in there time when they start and logs off when they stop. Its called PC Clock.
Now when users starts the computer it opens fine but when they restart the computer or logs off it doesn't work for Windows 10 computers (Works fine for Windows 7 computers)
What can we do to resolve this issue?
Thanks
1
Hello experts,

I have the following procedure to remove folders based on column A.
I would like to call cmd.exe and launch rmdir /q /s in folderPth
I am aware that I can use rmdir directly withtout calling CMD but I would like to remove it through cmd.exe.
Thank you in advance for your help.
Sub Remove_Folders()
Dim Ws As Worksheet
Dim i As Long
Dim LRow As Long
Dim Ans As Integer
Dim FSO As Object

Set Ws = ActiveSheet
Set FSO = CreateObject("Scripting.FileSystemObject")
LRow = Ws.Range("A" & Rows.Count).End(xlUp).Row

Ans = MsgBox("Before running this procedure, please check that" & _
             vbNewLine & "Folders to remove are reported in column A (initial range A2)" & _
             vbNewLine & "If so, please click on Yes else click on No.", vbQuestion + vbYesNo, "Confirm Please!")
If Ans = vbNo Then Exit Sub

      For i = 2 To LRow
      FolderPath = Ws.Range("A" & i).Value
        'Chek if folder end with \. If not create it
        If Right(FolderPath, 1) <> "\" Then
            FolderPath = FolderPath & "\"
        End If
        'Check if folder exist
        If Dir(FolderPath, vbDirectory) <> vbNullString Then
        'MsgBox "Folder exist", vbInformation
        Else
            MsgBox "Folder: " & FolderPath & " doesn't exist, operation has been aborted", vbInformation
            Exit Sub
        End If
    'add rmdir /q /s through cmd.exe
    MsgBox ("Folder " & FolderPath & " has been removed")
    Next i
End Sub

Open in new window

0
Hello experts,

I was wondering how to directly report folder path in a tree command.

I launch the following command
tree /a/f >tree.txt 

Open in new window

right after to a cd to reference folder.
Is there a way to directly report the folder path instead of executing cd previously?
Thank you very much for your help.
0
I have a mix of PCs/laptops that are standalone as well as those that join our AD/domain.

Have a public key that I wanted to import into the standalone PCs'  IE, Chrome & Firefox & was given steps below by vendor
for standalone PCs.  How can I automate the steps below (I have Desktop Central which could spawn a shell using the
non-interactive SYSTEM into them) & I have local administrator access to them (so I can issue
  'net use drive:  \\standalone_PC\c$ /user:administrator  admpassword' & copy files into them).

a)If there is no AD, you have to copy the certificate to clients.
b)On clients, go to IE > Tools > Internet Options > Content | Certificates.
c) On the Trusted Root Certification Authorities tab, click Import,  and Browse to the get_current_ca.cer
d) check "Place all certs in the following store"
e) change "Personal" to "Trusted Root Certification Authorities" & click Finish

Our users can't be trained to do steps a-e above, so need some sort of automation/scripts.

f) For PCs in the AD domain, modify the group policy to add the get_current_ca.cer into Trusted Root Certificate Authorities.
for step f above, as I'm not Wintel trained, can provide screen shot or will be something like what's mentioned in url below?
  https://support.securly.com/hc/en-us/articles/206688537-How-to-push-the-Securly-SSL-certificate-with-Active-Directory-GPO-

We disabled PowerShell, so Powershell scripting is not an option but  batch or VB scripting is allowed
0
Hello,
I need to export the various trigger of windows task scheduler in a csv & txt.
I supposed there is an option through cmd or powershell.

Could you please advice.
Thank you very much for your help.
1
I am creating a batch file to automate certain tasks along new PC deployments.

I have a custom power profile exported for my Dell machines. The file name is powerplan.pow

When I execute the command: powercfg -import "powerplan.pow" it returns

"Imported Power Scheme Successfully. GUID: 5c534448-baa1-47f2-8838-a83d7ef6928d.

The next line in the batch file would be: powercfg -setactive 5c534448-baa1-47f2-8838-a83d7ef6928d

How can I grab the GUID value returned from the "powercfg -import 'powerplan.pow'" command and append it to the powercfg -setactive <GUID value>" command?
0
Hello,

I am looking for a fast way to

1-Delete files with specific extensions .log, .txt .pdf

2-Delete files and exclude files with specific extensions such as .log, txt
Thank you very much for your help.
1

Windows Batch

12K

Solutions

11K

Contributors

Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.