Runas a certain xls file - excel

I need to write a batch script which opens a certain xls file on behalf of another user account.
runas separately works OK:
runas /profile /user:username "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE"
excel connector is also OK:
"C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE /r C:\fol der\file.xls"
but together it's not:
runas /profile /user:username "C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE /r C:\fol der\file.xls"
It can't handle the path of the xls file if there is space anywhere.

As per RUNAS - Execute a program under a different user account: RUNAS used backslash \ as an escape character (not the standard ^ used by other CMD commands). Moreover, runas /? gives next example literally:
runas /env /user:user#domain.microsoft.com "notepad \"my file.txt\""
Hence, your line should be as follows:
runas /profile /user:username "\"C:\Program Files (x86)\Microsoft Office\Office15\EXCEL.EXE\" /r \"C:\fol der\file.xls\""

Related

Encrypt a passsword using a pentaho job and store in file

here i have to create a job which coverts the plain text to encrypted password using below syntax
Windows:
Encr.bat -kettle <password>
Linux:
./encr.sh -kettle '<your-password>'
Note: the main problem I'm facing is i have to execute these commands inside data-integration folder alone.
Please hemp me out in this.
here i'm not sure of the location where its in server.
I tried to find the location of the folder using find command
./encr.sh -kettle '<your-password>
have to find the exact location of data-integration folder and execute command line command in this folder path
You can find the file executing this command:
Linux:
find / -name encr.sh
Windows:
dir encr.sh /s /p
Hope this helps.

Open folder in Command Prompt and path of current folder

When I click «Open in Command Prompt» in Visual Studio Code selected folder (C:\playground\ng2\app) should open in command line. But in command prompt display path C:\
printscreen
Have you configured the AutoRun setting for cmd.exe to cd \?

shortcut to program files (x86) directory

On my win32 system I had this command in Vim to open a vim file in wordpad:
silent ! start c:\Program Files (x86)\Windows NT\Accessories\wordpad.exe "%:p"<CR>
On my win64 system this doesn't work. I get this error:
error: Windows cannot find `"c:\Program"`
Maybe because of the space(s) inside "Program Files (x86)" and "Windows NT"?
How can i resolve this problem?
On 64-bit Windows wordpad.exe won't be in "Program Files (x86)", but in "Program Files". At least it is on my machine.
There are environment variables to find the folder names: "%ProgramFiles%" and "%ProgramFiles(x86)%".
Put quotes around your path.
Like so:
silent ! start "c:\Program Files (x86)\Windows NT\Accessories\wordpad.exe" "%:p"<CR>
Vim on Windows has a special !start (without a space in between) for asynchronous invocation.
And, as always, you need to put double quotes around the path, like this:
silent !start "c:\Program Files (x86)\Windows NT\Accessories\wordpad.exe" "%:p"

Zip batch command and Excel

I have many excel files that I need zipped into each of their own zip folders. I thought I had this ironed out, but I have co-workers coming back to me saying that they cannot open the excel file because it has become corrupted. I went back and checked the original file, and it opens up just fine. But when I open up the same version of the file that was zipped, I too get the corrupted error. I'm on Office 2010, which is able to repair it, but my co-workers are all Office 2007 which does not seem to be able to fix the file. My batch code is as follows:
for /r %%X in (*.xlsm) do "C:\Program Files\7-Zip\7z.exe" a -tzip "%%~nX" "%%X"
I think you might be using a wrong value as the first parameter to the 7zip executable. According to the documentation on FOR:
%~nI - expands %I to a file name only
And according to the 7zip documentation:
You can use the "a" command with the single letter a. This command stands for 'archive' or 'add'. Use it to put files in an archive. You have to specify the destination archive, and the source files (in that order).
So, using your script with an example file, it seems to me that your command line becomes:
"C:\Program Files\7-Zip\7z.exe" a -tzip "somefile.xlsm" "C:\path\to\somefile.xlsm"
Shouldn't the first parameter have a .zip file extension on the end? So the line is modified to look like this:
for /r %%X in (*.xlsm) do "C:\Program Files\7-Zip\7z.exe" a -tzip "%%~nX.zip" "%%X"
As annoying as it is, file extensions actually mean something in Windows. Your previous line was creating a zip file with the .xlsm extension. When people try opening those files, Excel complains (because it's a zip file; not a .xlsm).
#Echo OFF
PUSHD "C:\Program Files\7-Zip" && (
FOR /R "%CD%" %%# in (*.xlms) DO (7z a -tzip "%%~n#.zip" "%%#")
POPD
)
REM Don't worry about the PUSHD command, the %CD% variable isn't expanded, that's the trick.
Pause&Exit
And you can use the dynamic operator * (asterisk) and 7zip -recursive parameter if you want all together in one file:
7z a -r -tzip "ALL.zip" "*.xlsm"
Sorry guys.
It was a false alarm. Turns out it wasn't all of the files, but only a select few. The files were sectioned out by region, and the only ones that were corrupt were the first region. Why? I can only assume that they were corrupted by my original attempts at making a batch file, as all the other files were zipped with the finished batch and thus didn't have errors. So nothing was wrong with my script. Thanks for the help though.

How to do these permission granting commands in Windows Explorer?

In this tutorial, I found the following commands.
ICACLS "%SystemDrive%\Windows\System32\inetsrv\config" /Grant "Network Service":R /T
ICACLS "%SystemDrive%\Windows\System32\inetsrv\config\administration.config" /Grant "Network Service":R
ICACLS "%SystemDrive%\Windows\System32\inetsrv\config\redirection.config" /Grant "Network Service":R
How to do these using Windows Explorer?
What does the /T mean?
ICACLS is a command line tool. You need to use the comand line.
/T performs the operation on all specified files in the current directory and its subdirectories. http://msdn.microsoft.com/library/cc753525(v=WS.10).aspx

Resources