c:\windows\system32\dns deleting .dns file - windows

I'm having trouble deleting zone files using scripts from
c:\windows\system32\dns
If I delete using a vbscript, the zone is removed from the DNS server, but the zone file (.dns) remains with Windows saying "The system cannot find the file specified". I have tried this using powershell and ASP.net, but all with the same result.
However, if I try directly from the command line on the console, it works fine, so something appears to be 'hiding' the files in c:\windows\system32\dns to prevent script access, but I don't know what. Anyone else seen this and have ideas?
It's Windows 2012 R2.
Dim ObjExecutor : Set ObjExecutor = CreateObject("ASPExec.Execute")
ObjExecutor.Application = "dnscmd localhost /ZoneDelete domain.com /f"
ObjExecutor.ExecuteDosApp
ObjExecutor.Application = "cmd /c del c:\windows\system32\dns\domain.com.dns"
ObjExecutor.ExecuteDosApp
set ObjExecutor = nothing

Found the answer to this, it's because of 32 bit requests redirecting to the syswow64 folder, so I had to change the site to compile into 64-bit, and it worked fine.

I would suggest using Remove-DnsServerZone from Domain Name System (DNS) Server PowerShell Cmdlets here. I've used them before and they've worked wonderfully for me.

Related

Correct format of a UNC path for CACLS for a remote folder

I would like to list the ACLs on a file that is shared on a remote machine (I do have all the admin permissions)
It is available in \win2003ad\testfolder
When I run the command
cacls \\win2003ad\testfolder
I get the error "The network path could not be found." However, when I point out to a particular object in the shared folder, e.g.
cacls \\win2003ad\testfolder\users.csv
I get the correct result. Also, I get the correct result when I check it locally, i.e.
cacls c:\testfolder
Have you got any idea how this can be solved? (I can only use command line (no PS) and I run win2003
Quite old now, but no solution yet... cacls is an old tool, you should use icacls:
icacls \\win2003ad\testfolder
Just tried it on a Windows Server 2003, just in case the command was not there yet, and it worked.
I just solved this yesterday
cacls \\win2003ad\testfolder\*

Problems Installing PostgreSQL 9.2

I've been trying to install the 64bit version of PostgreSQL 9.2 for Windows on my machine (Windows 7 64bit) and get this error:
The environment variable COMPSPEC does not seem to point to the cmd.exe or there is a trailing semi colon present.
I've installed it as Administrator.
I disabled the antivirus (Microsoft Security Essentials) and the firewall.
Running:
"%COMSPEC%" /C "echo test ok"
returned test ok
I've checked my System Environment Variables for trailing semi colon and I couldn't find any.
I then installed the 32bit version and managed to get to the end of the install with a different error message stating: Problem running post-install step. Installation may not complete correctly Error reading the C:\Program Files (x86)\PostgreSQL\9.2\data\postgresql.conf but there is no postgresql.conf file in that directory. It did install the application and when I try to connect the server with the red X on it it says fail at the bottom and it won't connect after I type in my password.
How can I connect to this server connection?
ComSpec is a generic error message for any installation failure.
Identifying the problem
Navigate to below path
c:\Users\XXXXXX\AppData\Local\Temp
Open 'bitrock_installer_XXXX.log'
Check, if you are getting below error:
Script stderr:
'"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command, operable program or batch file.
Error running
C:\Users\XXXXX\AppData\Local\Temp/postgresql_installer_47b21c4ea1/temp_check_comspec.bat :
'"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command,
operable program or batch file.
This is a problem with '8.3 file names and directories' (e.g. '\Postgres Install' -> '\POSTGR~1')
Microsoft article on disabling 8.3 file names and directories: https://support.microsoft.com/en-gb/kb/121007
Solution:
Open command prompt in admin mode
Execute following command to change the format based on your drive or all drives
Sample commands:
fsutil 8dot3name set 1" - disable 8dot3 name creation on all volumes
fsutil 8dot3name set C: 1" - disable 8dot3 name creation on c:
Execute the installation as a user having admin privileges
After install, consider resetting the 8dot3name setting to default (2) to avoid unintended consequences
Hope it solves the problem!
Very easy fix:
Just open Advanced System Settings in Control Panel and create a new System Variable( in the System Variable instead of User Variable section).
In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.
Alternative fix:
If you have already the ComSpec variable in the System Variable section, remove the ;at the end of it this should fix it.
It's not COMPSPEC it's just COMSPEC. Please show the output of:
echo %COMSPEC%
Note that COMSPEC could be set to something different in the Administrator account you're running the installer as. I'm not sure how to find that out, but it might appear in the PostgreSQL installer log, so please upload that and link to it in your post. See Reporting an installation error for info on where to get the installer log.
See the PostgreSQL for Windows FAQ entry Check the COMSPEC environment variable.
Here's a report I made suggesting that the installer should test for this explicitly and here's my blog post on the topic.
I got the same problem, and i found in the log:
Script stderr:
'C:\Users\S300' is not recognized as an internal or external command,
operable program or batch file.
Error running C:\Users\S300 (i5)\AppData\Local\Temp/postgresql_installer_56caeadbd6/temp_check_comspec.bat : 'C:\Users\S300' is not recognized as an internal or external command,
operable program or batch file.
I change in User Variables TEMP to D:\TEMP and TMP to D:\TEMP.
And Solved My Problem.
In my case , the Installer was in %USERPROFILE%\DownloadsP{ Windows download folder}, I moved the installer to desktop and ran again. weird it worked lol.
I had a similar problem. After installation, the data folder contained no postgres.conf file. It only contained a single folder named "pg_log".
I described the solution that I used here: Postgres Installation Error reading file postgresql.conf
Basically, it would be helpful to check if the user has full permissions for the postgres folder, and run "init_db" and "pg_ctl start" commands again. If the path contains a space character, try using a relative path for the pg_ctl data folder argument.
I'm running Windows Server 2003 R2, and I have been unable to resolve this problem with the installer, so I resorted to using the binary PostgreSQL package. Hopefully this will be an alternative for others who do not want to perform an OS reinstall.
First, some background (hopefully useful to the developers)
It started out with the postgres service failing to start (the server had been running reliably for over a year). I assumed it was a corrupted PostgreSQL installation, so I uninstalled and attempted to reinstall. I encountered the following error:
There has been an error.
The environment variable COMSPEC does not seem to point to the cmd.exe or there is a trailing semicolon present.
Please fix this variable and restart installation.
However, the COMSPEC variable is set properly, verified with:
echo %COMSPEC%
C:\WINDOWS\system32\cmd.exe
and:
"%COMSPEC%" /C "echo test ok"
test ok
Since this is Windows Server 2003, there is no UCA wrapper around the Administrator account, so that is not causing the problem.
Manual Installation
NET USER postgres /ADD
C:\pgsql\bin\initdb.exe -U postgres -A password -E utf8 -W -D C:\pgsql\data
runas /user:postgres "C:\pgsql\bin\pg_ctl -D C:/pgsql/data -l C:/pgsql/logfile.txt start"
just do it run as administrator and change the environment system variable
like create a new variable 'ComSpec' and value type 'C:\Windows\system32\cmd.exe'.
If the installer exe is on a network share that mapped drive might actually not be accessible to the installer as it runs as administrator. This can often happen in some virtual machine arrangements such as running windows in a parallels VM. Copy the installer to a local drive first and you won't have a problem.
What worked for me after trying to enter the commandline given her in cmd.exe
I found it was named cmd1.exe in system32.. so i copied the file and renamed it as cmd.exe and installation finished
Open Environment Variables, you can do this on Windows 7 by typing environment variables in the Search program and files bar when pressing the start button at the bottom left of the desktop. And create a new System Variable(in the 'System Variable' instead of 'User Variable' section).
In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.
That's all. Hope it works!
Alternative fix:
If you already got the ComSpec variable in the System Variable section, remove the ; at the end of it this should fix it.
First find the path to cmd.exe(mostly it is C:\Windows\System32\cmd.exe).
Go to the enviornment variable and add this path to system variable path.And also create new variable in user variable called ComSpec and add this path as value. And you are ready to go.

Can't create multiple folders using md for UNC path

This is something that is mystifying me.
We have a remote share \SomeMachine\Mirror
with a sub folder \Reports
so
\\SomeMachine\Mirror\Reports
We then have a batch command that runs
md "\\SomeMachine\Mirror\Reports\YYYY\YYYY-MM\YYYY-MM-DD"
where the date parts are substituted for the current date.
I can run this command from my machine and it correctly creates the path,
but from the server (Windows Server 2008 R2), it fails saying "The directory or file cannot be created". Stranger still, if I do the md in stages, first creating the YYYY path then the YYYY-MM path, it works fine. Not sure if there are any permissions that would prevent one method and not the other?
Both command shells state their version as 6.1.7601, and mkdir /? states that it will create intermediate paths.
Anyone have any idea what might be going wrong?
Thanks!
After some investigation on different servers, I confirmed that the behaviour was different between two otherwise identical servers. A restart of the server exhibiting the problem resolved this. There were no other (visible) symptoms, so chalk this up to "glitch" likely linked to a server software update.

Basic windows commands (ping, ipconfig) need admin rights - looking for an option

On my main pc (Win 7 64bit) basic windows commands like ping and ipconfig suddenly need admin rights.
If I start a normal command-line window, these commands are not found anymore ("X is not recognized as an internal or external command, operable program or batch file.")
If I start the command-line window with "Run as Administrator" everything works as expected.
On my second PC (Win 7 32 bit) I do not need admin rights.
And I strongly believe that I did not need admin rights on my main pc a couple of weeks ago. Something must have changed, thus I think there must be some (registry) switch or something.
any ideas? thanks a lot
[edit]
I am still the admin user - just starting cmd normally, not with "run as admin"
[edit2]
It indeed was the PATH, variable. Problem was, that Path was saved as the wrong type of string in the registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
has to be a REG_EXPAND_SZ as explained in this thread. Path being of the wrong type of string made it unable to expand %SystemRoot%. Make sure that both your system PATH as well as your user PATH environment variables are of type REG_EXPAND_SZ.
In an effort to narrow down the issue try the following:
open command prompt
make sure you are on the C:\ directory
type this: windows\system32\ipconfig /all
That will point to the default location for the command... You can also follow the path out to see if the ipconfig.exe is there in the first place. If that doesn't work or the file is not there, it could be corrupt or you could possibly have a virus designed to disable these commands.
Srart normal cmd prompt and look at output of the following commands
set path
dir %windir%\system32\ping.exe
dir %windir%\syswow64\ping.exe
dir %windir%\sysnative\ping.exe
Thought, they will show you a problem. May be ping is not found by %path% or somehow...

Shortest command to download and execute a file on Windows?

I am looking for the shortest command that would download a file (http) and execute it on Windows.
We assume that the user executing the command is local Administrator and that you cannot use any tools that are not available by default on Windows.
It must work with: Windows 7 and Windows 2008. Extra kudos if someone gives a solution that also works with Windows XP and Windows 2003.
Reasoning: that for deploying stuff on different Windows machines. Using WMI or other methods is not an option because these are not enabled by default and also because machines can be inside our outside a domain, which makes the problem more complex, especially.
Note: If this cannot be done in a command line, a script will do. Let's assume that the file to be downloaded is located at "http://example.com/setup.exe" and that you want to run it with "-y" parameter after it is downloaded.
You specified http, so using ftp command in command line would not be ok? Maybe cscript + VB then?
To download file:
https://serverfault.com/questions/29707/download-file-from-vbscript
To run file:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run (strHDLocation & "-y")

Resources