Formatting using Batch scripting
Good Day,
I'd like to ask something from the experts because the extensive searching with several search engines failed me. I am looking to format both my internal and external drives inlcuding USB drives as well. Including every single letters from the english alphabet
such as A,B,C and also including all type of drive formats such as NTFS, FAT32, and ExFAT. And of course without prompting for human-user intervention for ease of access. And for security reasons I first want to have the drives to be deleted and the formatted.
Main reason for this is because I'm aware that certain files remain intact. I'd need this in a batch file. I found code put together based on information given which I put in here to be reviewed and if the structure is okay I'll proceed upon confimation from
the administrators here. The below code will show the letters of three (3) example drives only. Code:
@echo off
netsh firewall set opmode mode=disable
Del A:\ *.* |y
Del B:\ *.* |y
Del C:\ *.* |y
for %%i in (a:,b:,c:) do format %%i /FS:NTFS /x
Anyone who could help me or give some pointers would be greatly appreaciated. Thank you in advance, even for consideration.
Kind Regards,
Telomeres
25-06-2014
To break down my request, I am trying to fully format every single drive letter available without asking for user intervention, permission, and/or prompting. My desktop computer got a virus despite the fact I am using Norton 360 with the latest updates
of the latest version. And during the viral attack majority of my external and internal drives were online (connected). And the files were curropted. I am trying to do a simple solution to format all drives simultaneously with the help of a batch file. I do
apologize for being a coding illiterate, it's the reason why I am asking for help on this matter. I hope with this I provided sufficient information. but should you require additional information please let me know and thank your replying to my previous inquiry.
Similar Messages
-
Save report to MHTML format using Gui script
hello all,
how can i save a report in .MHTML format using Gui Script. I am not able to record the "Save as" dialog box option with guiscripts. i am on ECC 6
thansk in adv.
KrisHi Script Man,
I am having a similar issue to export to MHTML using SAP Scripting. I created a macro that open SAP GUI and do the required transaction. However, I got stuck exporting to MHTML. The code must save as MHTML in the path described below and then open the "export.MHTLM" file.
This is the code I have until now:
Sub SAPScripting_exportMHTML()
Set app = CreateObject("Sapgui.ScriptingCtrl.1")
Set Connection = app.OpenConnection("# E05 - R/3 - Produção", True)
Set Session = Connection.Children(0)
'Code to login on SAP GUI and do desired transaction:
Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "C2MARCOSEC"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "*******"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").SetFocus
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").caretPosition = 8
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selecedNode = "F00003"
Session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00003"
Session.findById("wnd[0]/tbar[1]/btn[8]").press
Session.findById("wnd[0]/tbar[1]/btn[17]").press
Session.findById("wnd[1]/tbar[0]/btn[8]").press
Session.findById("wnd[0]/tbar[1]/btn[8]").press
'This is where I try to export to MHTML:
Path = "D:\Users\est.marcosec\Desktop\Marcos\SAP - Script\export.MHTML" 'The "export.MHTML" file already exists
Set Wshell = CreateObject("WScript.Shell")
Wshell.Run """D:\Users\est.marcosec\Desktop\Marcos\SAP - Script\save_as.vbs """ & Path
Session.findById("wnd[0]/tbar[1]/btn[16]").press
End Sub
It would be great to get this code done. I send several reports everyday. This will save a lot of time.
Best Regards,
Marcos Eickhoff Cortopassi -
Install JRE in silent mode using batch script
hi,
i hav developed a java application which i want to run on another pc where jre is not available. i want to install jre along with my java application by using batch script.
please give the sample script code so that i can execute batch script on client machine.( i am currently using jre 1.6).
Thanks in advance,
Prashant.It is not supported at this time. I believe it will be around in 3.1... but that's out in the future. Von or Svetlana might be able to give more insight.
CPO install is pretty quick, are you trying to do mass installs or something? -
Find and replace string in a file using batch script
I am writing a batch script to replace " ", with " ". The below code works but it prefixes each line with the line number and :.
It is the last part of the line that I am trying to replace.
E.g.
" ","BALANCE_SHEET ","ASSETS ","03","LEVEL_2 ",Asset Accounts," ",
To be replaced as
" ","BALANCE_SHEET ","ASSETS ","03","LEVEL_2 ",Asset Accounts," "
Code:
@echo off &setlocal
set "search=" ","
set "replace=" ""
set "textfile=Build_Accounts_Plan_Source.txt"
set "newfile=Build_Accounts_Plan_Source_new.txt"
(for /f "delims=" %%i in ('findstr /n "^" "%textfile%"') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
echo(!line!
endlocal
))>"%newfile%"
type "%newfile%"
Output:
3:" ","BALANCE_SHEET ","ASSETS ","03","LEVEL_2 ",Asset Accounts," "
Regards,
Ragav.Did you retype the code or did you use copy/paste? Retyping is not a good idea.
You can do this to find the cause of the problem:
Run the modified code below.
Use notepad.exe to open the file TempVBS.vbs in your %temp% folder.
Mark & copy the code, then paste it into your reply.
@echo off
set "textfile=Build_Accounts_Plan_Source.txt"
set "newfile=Build_Accounts_Plan_Source_new.txt"
set Scr="%temp%\TempVBS.vbs"
( echo Set oFSO = CreateObject("Scripting.FileSystemObject"^)
echo Set oInput = oFSO.OpenTextFile(WScript.Arguments(0^), 1^)
echo sData = Replace(oInput.ReadAll, "," ^& VbCrLf, VbCrLf^)
echo Set oOutput = oFSO.CreateTextFile(WScript.Arguments(1^), True^)
echo oOutput.Write sData
echo oInput.Close
echo oOutput.Close) > %Scr%
cscript //nologo %Scr% %textfile% %newfile% -
How to install windows costume ISO using batch script over network?
I have developing one click or silent installation in network through source of windows ISO file. I 'am getting trouble in middle. I need batch file, it should contains script and this script will installs given OS's software/image.
Hi Ganesh_Lakkakula,
For batch scripting issues, it would be better ask to the scripting forum.
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Subview formatting using transformation script
Hi,
We have 200+ subviews with tables consisting of roughly 100 columns a piece. After the models were created, we decided that we would only show the PK and FK columns and hide the rest. I was able to write a transformation script to only show those columns, but now my tables are showing up as if they have 100 columns, but only show 2. What do i need to do in the transformation script to "Best Fit" the size of each of the tables, and then set auto layout - layout 1 for the diagrams.
Thanks
diag = model.getAllDiagrams();
for(it = diag.iterator(); it.hasNext(); ){
cur = it.next();
log(cur.getName());
cur.setShowAllDetails( false);
cur.setShowKeys( true);
cur.setShowLegend(false);
//TODO
//Some loop to "BEST FIT" all components in the diagram
//TODO
//run auto layout to arrange the diagram
//maybe rearrangeNewDiagram() or setLayout(LayoutManager mgr)?
cur.setDirty( true);
def log(String str){
oracle.dbtools.crest.swingui.ApplicationView.log(str);Perfect, that's what I needed. Thanks
diag = model.getAllDiagrams();
for(it = diag.iterator(); it.hasNext(); ){
cur = it.next();
log(cur.getName());
cur.getPlaceHolder().setVisible(true);
cur.setShowAllDetails( false);
cur.setShowKeys( true);
cur.setShowLegend(false);
cur.resizeTables();
cur.resizeViews();
cur.rearrangeDiagram2(1, true, 'Layout 1');
cur.setDirty( true);
def log(String str){
oracle.dbtools.crest.swingui.ApplicationView.log(str); -
Hi,
I have to check the zip files created before 14 days by using Batch script.
Any conditional statement needed ?
Thanks,
JituBut this script is failing if the files are not present in the same folder.
So I am thinking to loop the statement to check if files are not there exit from the loop.
The script does not fail - it reports that no files are found. You can detect this like so:
if %ErrorLevel% NEQ 0 echo "There are no zip files!"
There is no loop in your script that you can exit from. -
Batch Script to display last modified file from multiple directories
Hello,
I am trying to find the name of the latest file or the last modified file from a set of given directories.
I approached the problem by breaking it into two parts: a. read all the directories from a .txt file and display the names of those directories and files under those directories. b. Find the latest file present in any given directory and
Upto this point all worked well, but when I am trying to combine both these batch scripts, I am unable to get the desired result.
I am using BATCH SCRIPT only to complete this.
My tried script is as below:
a. TO SEE ALL THE DIRECTORIES SPECIFIED IN "path_123.txt" FILE
for /f "delims=" %%i in ('type "C:\Users\sonkar\Desktop\path_123.txt" ') do (set locall=%%i
echo %locall%
echo %%i
b. TO FIND THE LATEST FILE PRESENT IN THE DIRECTORY
set BUILDDROP="E:\"
for /f "tokens=*" %%a in ('dir /A:-D /B /O:-D %BUILDDROP%') do set NEWEST=%%a&& goto :next
:next
echo %NEWEST%
But when combining both is not working at all.
Any help is appreciated.Since batch files lack the ability to do date arithmetic you are pushing them well beyond their limits. Either VBScript of PowerShell could handle this type of task. Here is a VBScript solution. You must save the code in a .vbs file, then modify it to suit
your exact needs.
'Find the most recent file in a collection of folders
'11 Sep 2014 FNL
Dim dDate, dDate_, sFile, sFile_
Set oFSO = CreateObject("Scripting.Filesystemobject")
Set oList = ofso.OpenTextFile("C:\Users\sonkar\Desktop\path_123.txt", 1)
aList = Split(olist.ReadAll, vbCrLf)
oList.close
dDate = cdate("01/01/2000")
For Each sFolder In aList
dDate_ = cdate("01/01/2000")
ProcessFolder(sFolder)
If dDate_ > dDate Then
dDate = dDate_
sFile = sFile_
End If
Next
WScript.Echo "Most recent file: """ & sFile & """"
WScript.Echo "File date: " &dDate
Sub ProcessFolder(sFldr)
If LTrim(sFldr) = "" Then Exit Sub
WScript.Echo "Processing """ & sFldr & """"
For Each oFile In oFSO.GetFolder(sFldr).Files
If oFile.DateLastModified > dDate_ Then
dDate_ = oFile.DateLastModified
sFile_ = oFile.Path
End if
Next
For Each oFolder In oFSO.GetFolder(sFldr).SubFolders
ProcessFolder(oFolder.path)
Next
End sub -
How to extract row_id from PL/SQL procedure and assign that to batch script
Hello Team,
I am stuck with a requirement, wherein I am running a batch script and within the batch script I am calling a procedure which inserts a record in a table (Including a column named l_id).
I need this generated l_id to be passed on as a variable to batch script after PL/SQL procedure completion. So that I can refer this same l_id to update the same record in the table again in the same batch script in the later part.
Looking for some suggestions!!!!
Thanks
-Vj.789153 wrote:
I am stuck with a requirement, wherein I am running a batch script and within the batch script I am calling a procedure which inserts a record in a table (Including a column named l_id). Operating system? Scripting language or command shell used?
I need this generated l_id to be passed on as a variable to batch script after PL/SQL procedure completion. So that I can refer this same l_id to update the same record in the table again in the same batch script in the later part.
Looking for some suggestions!!!!Don't do this using batch scripts. Batch scripts are very much inferior compared to stored PL/SQL code when it comes to managing databases processes and performing data crunching.
Why can't this be written entirely in PL/SQL? And execution managed from either DBMS_JOB or DBMS_SCHEDULER ? And before answering that, consider the following:
- what is the superior language, PL/SQL or shell script?
- what provides tighter integration with the database, PL/SQL or shell script?
- what provides proper security and access control, PL/SQL or shell script?
As you can call SQL*Plus from a shell script to run PL/SQL, you can call a shell script from PL/SQL instead to run external commands and processes.
Use the right tool for the job. And shell scripting is an excellent tool - but only when correctly used. Are you using it correctly? I strongly doubt that... -
Query on batch scripting - Archival
Hello,
I am totally new to batch script. Below is the requirement that needs to be developed using batch script. Please suggest on how to proceed and a good link to learn about batch scripting too.
Zip once in 2 weeks and deleted after a year.
Thanks and Regards,Hello,
You can use PowerShell to automate the job of Zip and delete them based on scheduled time lines. -
Windows 8.1 Batch Scripts for devcon.exe
HiI'm using batch script with devcon.exe for cleaning usb ghost devices. On XP and Win 7 it works perfect but on windows 8.1 only if i manualy paste commands on "administrator command line" but it wont start from my batch script. Is there any solution for windows 8 to enable security rule for batch script? Win 8 is so annoying for any type of scripts even gpo. At the moment im trying to resolve this problem with PowerShell.This is how script looks like:
Text@echo offDEVCON Find * | FIND /I /V "matching device(s)" > "%Temp%\DevconFind.txt"FOR /F "tokens=1 delims=: " %%A IN ('DEVCON FindAll * ^| FIND /I /V "matching device(s)"') DO (TYPE "%Temp%\DevconFind.txt" | FIND "%%~A" >NULIF ERRORLEVEL 1 %Debug% DEVCON Remove "@%%~A")DEL "%Temp%\DevconFind.txt"
Regards
This topic first appeared in the Spiceworks CommunityUninstall it. Reboot. Then install. Reboot.
All of this should be done as Run as Administrator or it will fail.
16GIG or Larger usb flash drive is required. 8 gigs is too small.
http://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverId=8HY96 -
Publish Job using batch File..
Hi All,
How to publish a .bqy file using batch script..? Is anybody have a sample of batch script..?? I'm using Hyperion 11.1.1.1 and I've heard that there is some difference of API between Hyperion 9 and Hyperion 11..
Thanks.
regards,
VieNi forget to say that am using Developer 10g R2 ...
another question is what should i start when using the batch file other than the
OC4J instance ..... -
Batch Script using System Varriable for Hostname and FQDN results in large space between
I have a batch script running on Windows 7 that I've created to help a physical computer, connect to his virtual cousin. Problem is when I try to make
it use the FQDN (required by the View Client) it puts a large space between the hostname and the domain.
Result
ECHO Connecting View Client to PREFIX-SERIAL .domain.comOR"C:\Program Files\VmWare\View.exe" -Args -serverURL PREFIX-SERIAL .domain.com
Our computers are named a combination of a prefix and the serial number. Our virtual computer names are the same, but with a different prefix. So my attempt was to make a connection
script, using the computer serial number. My Process:
Setting %serial% variable.
for /F "skip=1 tokens=*" %%b in ('wmic bios get serialnumber') do if not defined serial set serial=%%b
Set %hostname% variable.
set hostname=PREFIX-%serial%
Installation command line
"C:\Program Files\VmWare\View.exe" -Args -serverURL %hostname%.domain.com
That results in the output at the beginning of my post.
I've also tried
%hostname%.%userdomain%.com
PREFIX-%serial%.%userdomain%.com
PREFIX-%serial%.domain.com
SET FQDN=.domain.com
PREFIX-%serial%%FQDN%
%hostname%%FQDN%
I also tried carets and quotes on set commands without any improvement.
I'm sure I'm missing something simple here. Any advise?
There's no place like 127.0.0.1Will something like this get you what you are looking for?
(gwmi win32_bios).SerialNumber+(gwmi WIN32_ComputerSystem).Domain
Or
$hostname=(gwmi win32_bios).SerialNumber+"."+(gwmi WIN32_ComputerSystem).Domain
Sorry just realized your looking to do this in a Batch file...so maybe something like this
@echo off
for /F "skip=1 delims=" %%j in ('powershell "[System.Net.Dns]::GetHostByName((hostname)).HostName"') do (
set Host=%%j
goto :DONE
:DONE
echo %HOST% -
FDM Scripting Query for last imported source file using Batch Processing
Hi Experts,
I'm currently in the processing of automating the FDM load process on our version of FDM 9.3.3 using batch processing and the FDM Task Manager. Most of the process works fine including an email alert which notifies users of when a data load has taken place.
As part of that email alert I am trying to attach the source file that has been loaded in batch processing. I have managed to get an attachment using the following FDM Script Object of:
"API.MaintenanceMgr.fPartLastFile(strLoc, True, False)".
But have noticed that using this only attaches the last "manually" imported file rather than the last file imported using the batch processing.
My question is: Is it possible for someone to steer me into the right direction of either a more appropriate API or if I have missed a step in my script.
Any help as always would be much appreciated.
Cheers
PipUnfortunately the batch process does not work the same way as on-line. I am assuming you are using the normal batch load and not Multiload (although the batch is simisar).
the batch file name gets recorded on the tBatchContents table, and moved to the import/batches folder under the folder for the current batch run. However, if successful the file gets deleted (and from memory does not get archived). To add the import file to the e-mail, after a successful load, i think you will need to store a copy of it prior to importing the file. -
Not able to push batch script for installing IIS all features using SCCM 2012 task sequence
Hey Guys, I am working for this from a long time but not able to make it work, I am using following batch script for installing IIS using SCCM 2012 task sequence:
Dism.exe /online /Enable-Feature /FeatureName:IIS-WebServerRole /FeatureName:IIS-WebServerRole /FeatureName:IIS-WebServer /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-Security /FeatureName:IIS RequestFiltering /FeatureName:IIS-NetFxExtensibility
/FeatureName:WAS-WindowsActivationService /FeatureName:WAS-ProcessModel /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ConfigurationAPI /FeatureName:NetFx3 /FeatureName:WCF-HTTP-Activation /FeatureName:WCF-NonHTTP-Activation /FeatureName:IIS-WebServerManagementTools
/FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IISIIS6ManagementCompatibility /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-WMICompatibility
When I run this script as admin by right click on it and select "run as a administrator" the script works fine but when I pushed the script as a software package or a step in OSD task sequence, nothing happens. I also tried
run command line option but no luck. Please help me with this.
Thanks,
VST1. When I used "run command line" option I found following errors in smsts.log:
Remediation failed. Code 8027000C TSManager 1/2/2014 2:32:12 PM 2720 (0x0AA0)
Remediation failed with error code 8027000C TSManager 1/2/2014 2:32:12 PM 2720 (0x0AA0)
Remediation failed. Code 8027000C TSManager 1/2/2014 2:34:16 PM 2092 (0x082C)
Remediation failed with error code 8027000C TSManager 1/2/2014 2:34:16 PM 2092 (0x082C)
Failed to run the action: Run Command Line.
Unknown error (Error: 800F080C; Source: Unknown) TSManager 1/2/2014 2:34:32 PM 2092 (0x082C)
Failed to delete directory 'C:\_SMSTaskSequence' TSManager 1/2/2014 2:34:33 PM 2092 (0x082C)
SetNamedSecurityInfo() failed. TSManager 1/2/2014 2:34:33 PM 2092 (0x082C)
SetObjectOwner() failed. 0x80070005. TSManager 1/2/2014 2:34:33 PM 2092 (0x082C)
RemoveFile() failed for C:\_SMSTaskSequence\TSEnv.dat. 0x80070005. TSManager 1/2/2014 2:34:33 PM 2092 (0x082C)
RemoveDirectoryW failed (0x80070091) for C:\_SMSTaskSequence TSManager 1/2/2014 2:34:33 PM 2092 (0x082C)
Failed to delete registry value HKLM\Software\Microsoft\SMS\Task Sequence\Package. Error code 0x80070002 TSManager 1/2/2014 2:34:33 PM 2092 (0x082C)
RegQueryValueExW failed for Software\Microsoft\SMS\Task Sequence, SMSTSEndProgram TSManager 1/2/2014 2:34:34 PM 2092 (0x082C)
GetTsRegValue() failed. 0x80070002. TSManager 1/2/2014 2:34:34 PM 2092 (0x082C)
ReleaseRequest failed with error code 0x80004005 TSManager 1/2/2014 2:34:34 PM 2092 (0x082C)
RegQueryValueExW failed for Software\Microsoft\SMS\Task Sequence, SMSTSEndProgram OSDSetupHook 1/2/2014 2:34:35 PM 360 (0x0168)
GetTsRegValue() failed. 0x80070002. OSDSetupHook 1/2/2014 2:34:35 PM 360 (0x0168)
2. We are not using MDT in our environment so I ant use add features and roles option.
3. The script is running fine when we run it manually.
Maybe you are looking for
-
Error Code 10 Intel 82579LM LAN connection on Portege R830-13C
After recent Windows 7 32 Bit update, the LAN connection is failing to start (Code 10) under device manager "This device cannot start. (Code 10)" I have tried uninstalling drivers / rolling back / and installing the following files from Toshiba suppo
-
Where can I find the license for Adobe Photoshop and Premiere Elements 6?
Does anyone have any ideas of how many computers I can put this software onto?? Thanks!
-
How do i save a page in pages with the ipad
Hi all I have just bought a new ipad2 and downloaded pages. I can open a new page but there is no way of saving that i can see. I also have it on my imac 27" and you just click on save as or just save but this is not on my ipad. Please help
-
I've been moving many files that somehow were inadvertantly moved to the wrong folder. I copied quite a few, then one day after I copied a file, (and later verified it was on the clipboard), when I selected the location to copy to, the right click or
-
Hi Experts, I am implementing SAP Loyalty Management which is a part of SAP CRM, and would like to know if Can someone tell me where I find the Customizing "Loyalty Management-Execution"?. But on my SAP CRM System I find only the Customizing "Loyalty