We are in the process of moving over 100 domains over to a new server. I have created a script that will allow adding a Website entry and FTP entry into IIS 7 using a simple BAT file. I found several tutorials using AppCmd ADD SITE which works very well. By running :: c:\scripts\createIIS.bat youdomainname.com . Any feed-back? - It is working.
#Echo off
:: --------------------------------------------
:: Create IIS 7 Site Entry / FTP Site
:: --------------------------------------------
:: Get variable from command %1 Root Domain Name.
set rootDomainName = %1
:: This is the path to the Web Pages on the server.
set WebFile=C:\websites\
:: ADD NEW Directory
MKDIR %WebFile%%1
:: ADD IIS ENTRY
%windir%\system32\inetsrv\AppCmd ADD SITE /name:%1 /bindings:http/*:80:%1,http/*:80:www.%1 /physicalPath:C:\websites\%1
:: --------------------------------------------
:: CREATE FTP in IIS
:: --------------------------------------------
%windir%\system32\inetsrv\AppCmd add vdir /app.name:"Default FTP Site/" /path:/%1 /physicalPath:"%WebFile%%1"
echo New Directory Created: %WebFile%%1
echo IIS Website Created: %1 and www.%1
echo FTP SITE Created: %1
echo ...
echo ...
echo COMPLETED!
pause
Great script. Even though this isn't really a question, I modified it somewhat for batch processing.
First, I created a batch file that reads in a text file of websites to add, that references your slightly modified batch file to only create websites (no FTP's required):
#Echo off
:: ---------------------------------------------------------------------------------------
:: Create Batched IIS 7 Site Entries
::
:: Usage: CreateIISEntry.bat [websitename.com] (no www.)
::
for /f %%X in (NewWebsiteEntries.txt) do CreateSingleIISEntry.bat %%X
echo ...
echo *** BATCH PROCESS HAS BEEN COMPLETED ***
NewWebsiteEntries.txt contains a list of websites to create - one per line (no www. included):
site1.com
site2.com
site3.com
Lastly, the batch file that creates the entries:
#Echo off
:: ---------------------------------------------------------------------------------------
:: Create IIS 7 Site Entry
::
:: Usage: CreateSingleIISEntry.bat [websitename.com] (no www.)
:: ---------------------------------------------------------------------------------------
:: Get variable from command %1 Root Domain Name.
set rootDomainName = %1
:: This is the path to the Web Pages on the server.
set WebFile=C:\inetpub\wwwroot\
:: ADD NEW Directory
MKDIR %WebFile%%1
echo New Directory Created: %WebFile%%1
xcopy C:\inetpub\wwwroot\NewWebsiteHolding\*.* %WebFile%%1
:: ADD IIS ENTRY
%windir%\system32\inetsrv\AppCmd ADD SITE /name:%1 /bindings:http/[YOUR IP ADDRESS OR *]:80:%1,http/[YOUR IP ADDRESS OR *]:80:www.%1 /physicalPath:%WebFile%%1
echo IIS Website Created: %1 and www.%1
#:: --------------------------------------------
#:: CREATE FTP in IIS
#:: --------------------------------------------
#%windir%\system32\inetsrv\AppCmd add vdir /app.name:"Default FTP Site/" /path:/%1 /physicalPath:"%WebFile%%1"
#
#
#echo FTP SITE Created: %1
echo ...
echo ...
echo New website added ========================= %1
Since in my case, not all the new sites will be live at once, I a default placeholder site who's contents are copied into the newly-created website directories.
This will add all sites to the default app pool.
That's about it.
Related
I have Bluetooth headphone, sometimes windows 10 fails to connect with Bluetooth device so I need to go to task manager -> Services - Open Services -> Find Bluetooth Support Service and restart it.
I was curious if I can make any shortcut or batch file operation or kind of script and I can just click on it and it will restart Bluetooth Support Service.
First, find your service name by typing this command:
powershell -Command "sc.exe query | Select-String -Pattern Bluetooth -Context 1,0"
You'll find your service's name with the string SERVICE_NAME just above the DISPLAY_NAME you searched for. It can be something like UmRdpService or RasMan, whatever.
Then, in an ELEVATED command prompt, type these two commands:
sc stop YourServiceNameFoundAbove
sc start YourServiceNameFoundAbove
Your service is now restarted.
You can use the following batch, it will ask automatically for elevation if needed.
Just modify the line set SRV=... and save it where it suits you, then you simply need to create a shortcut manually (done only once) on your desktop.
#echo off
setlocal EnableExtensions EnableDelayedExpansion
set SRV=YourServiceNameFoundPreviously
REM Check admin mode, auto-elevate if required.
openfiles > NUL 2>&1 || (
REM Not elevated. Do it.
echo createObject^("Shell.Application"^).shellExecute "%~dpnx0", "%*", "", "runas">"%TEMP%\%~n0.vbs"
cscript /nologo "%TEMP%\%~n0.vbs"
goto :eof
)
del /s /q "%TEMP%\%~n0.vbs" > NUL 2>&1
sc stop !SRV! || (
echo ERROR: Couldn't stop service !SRV!.
pause
goto :eof
)
sc start !SRV! || (
echo ERROR: Couldn't start service !SRV!.
pause
goto :eof
)
goto :eof
I want to install WordPress. Sounds easy, but unexpected errors occurs.
The install page loaded with only html content (no style ). when you click next, a
"Forbidden You don't have permission to access this resource."
All requested file permissions and .htaccess are verified.
The server have let's encrypt SSL and HTTP/2 enabled.
Any Idea
I never had any problems installing Wordpress on a http2 server.
If you are on a linux server with shell-access: navigate in your wordpress directory and try this in the SSH console to set the permissions right:
chown USER:GROUP -R *
chown all files & directories (recursive) to the Webservers USER & GROUP. Replace USER & GROUP with the CORRECT (!) values depending on your hosting. Something like www-data:www-data for example).
You can find the right USER & GROUP if you check another directory or file that is automatically created by the hosting (error docs or the httpdocs folder - depends on your hosting)
Then:
find . -type d -exec chmod 755 {} \;
(set all subdirectories to 755)
find . -type f -exec chmod 644 {} \;
(set all files to to 644)
Regards Tom
I have two different servers. I use WinSCP to transfer a folder manually:
I connect to SFTP on SVR-01 -> Transfer folder to my local machine
I connect to SFTP on SVR-02 -> Transfer folder from my local machine to SVR-02
What I want?:
I would like to do it automatically.
Example: in a command OR script, the SVR-01 transfer folder /opt/home/files-everyday/ to SVR-02 /opt/backup/
When transfer is finished, delete /opt/home/files-everyday/ from SVR-01.
This should be done every day.
One folder is created every day by date "20150613" in SVR-01 and this folder to be automatically transferred to the SVR-02.
You can use WinSCP scripting from a Windows batch file:
#echo off
mkdir %temp%\intermediate
winscp.com /log=c:\path\log.log /command ^
"open sftp://user1:password1#server1.example.com/ -hostkey=""ssh-rsa 2048 87:d6...a7""" ^
"get /opt/home/files-everyday/* %temp%\intermediate\" ^
"open ftps://user2:password2#server2.example.com/" ^
"put %temp%\intermediate\* /opt/backup/" ^
"session 1" ^
"rm /opt/home/files-everyday/*" ^
"exit"
rmdir /q /s %temp%\intermediate
Then use the Windows scheduler to run the script regularly (every day).
I'm trying to automate a manual work of copying a specific file from many network client machines.
All clients will have a file that have to be backed up from time to time.
for that i have a list of client hostnames. and the file to be backed up is in a shared folder of each host.
Now I want a batch file that creates a new folder with "dd-mm-yyyy"format and copies all the files in to a masterHost.
for that i have wrote
#echo off
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%dd%-%mm%-%yyyy%
echo New folder name %date%
MKDIR \\MasterHost\d$\%date%
copy \\client1\c$\data\data.txt \\MasterHost\d$\%date%\client1data.txt
copy \\client2\c$\data\data.txt \\MasterHost\d$\%date%\client2data.txt
copy \\client3\c$\data\data.txt \\MasterHost\d$\%date%\client3data.txt
copy \\client4\c$\data\data.txt \\MasterHost\d$\%date%\client4data.txt
copy \\client5\c$\data\data.txt \\MasterHost\d$\%date%\client5data.txt
now can anyone help me getting the client name from a file that has list of client hostnames say hostList.txt because i dont want to manually enter the host names each time...
the hostList.txt will look like this
client1
client2
client3
client4
client5
.
.
.
etc
Even a small help will be appreciated because i'm new to batch scripting. Thanks
You can try something like this:
for /F %x in ('type hostList.txt') do (
copy \\%x\c$\data\data.txt \\MasterHost\d$\%date%\client1data.txt
)
instead of all the copy... lines.
I recently setup mail server using zpanel (with dovecot and Maildir format) for my domain and created a user email account with user#my-domain.com here.
Here all the emails are stored in following tree in server under /var/zpanel/vmail/ path
my-domain.com
|--> cur/
| ------
|--> new/
| ------
|--> tmp/
------
I have all user email from my old server (in same format as above). Where email server for my domain my-domain.com was be hosted before.
Problem is, I already have few emails on new server for user and I want to merge both so that it show up all email which I sent from New email server and old one.
Is there any way, I can merge these two maildirs?
Sorry, But I figured out how we can do it. Just answering my question here so that will be useful for others as well.
We can do it using simple filesystem merge for directories but after that we need to make sure that we give appropriate permission to all files for vmail user (user might be specific to zpanel).
This is what worked for me . Under /var/zpanel/vmail/my-domain.com/cur/:
$ sudo chown vmail:mail *
Same we need to do for /new and /tmp directories.
You can use cp -Rp to recursively copy folder contents while maintaining ownership and permissions and then delete the old folder.
For example, to merge "INBOX/something" to "INBOX" with dovecot:
# from the dovecot mail folder
cp -Rp .INBOX.something/* ./
rm -rf .INBOX.something