Cannot open: c:\users\...\temp\package.cab when running Process.Start

329 views Asked by At

Hello I got this little script of microsoft:

@echo off
rem *** Author: T. Wittrock, Kiel ***

if not exist "%TEMP%\wsusscn2.cab" (
  .\bin\wget.exe -N -i .\static\StaticDownloadLinks-wsus.txt -P "%TEMP%"
  if exist "%TEMP%\wuredist.cab" del "%TEMP%\wuredist.cab"
  if exist "%TEMP%\WindowsUpdateAgent30-x64.exe" del "%TEMP%\WindowsUpdateAgent30-x64.exe"
  if exist "%TEMP%\WindowsUpdateAgent30-x86.exe" del "%TEMP%\WindowsUpdateAgent30-x86.exe"
)
if exist "%TEMP%\package.cab" del "%TEMP%\package.cab"
if exist "%TEMP%\package.xml" del "%TEMP%\package.xml"
%SystemRoot%\System32\expand.exe "%TEMP%\wsusscn2.cab" -F:package.cab "%TEMP%"
%SystemRoot%\System32\expand.exe "%TEMP%\package.cab" "%TEMP%\package.xml"
del "%TEMP%\package.cab"


%SystemRoot%\System32\cscript.exe //Nologo //E:vbs .\cmd\XSLT.vbs "%TEMP%\package.xml" .\xslt\ExtractDownloadLinks-w60-x64-glb.xsl "%TEMP%\DownloadLinks-all.txt"


%SystemRoot%\System32\cscript.exe //Nologo //E:vbs .\cmd\XSLT.vbs "%TEMP%\package.xml" .\xslt\ExtractDownloadLinks-w60-x86-glb.xsl "%TEMP%\DownloadLinks-all.txt"

del "%TEMP%\package.xml"
del "%TEMP%\wsusscn2.cab"

:EoF

I runs perfectly when I double click it. I try to open it through C# with the follow code:

System.Diagnostics.Process.Start("C:\\Users\\me\\Desktop\\trunk-r664\\trunk\\ExtractDownloadLinks-all");

But when I run this it gives a error in the cmd, saying:

Can not open input file: c:\users\me\appdata\local\temp\packacge.cab
Can not open input file: c:\users\me\appdata\local\temp\wsusscn2.cab

I guess the best option to fix this is to chance the script of Microsoft? But I have no idea how. Or maybe there is a solution in C# for this?

Thanks in advance

1

There are 1 answers

0
wouter On

I got help of someone who knows a lot about wsus offline and knows how to script. I ask the same question on here: http://forums.wsusoffline.net/viewtopic.php?f=4&t=5001&p=15991#p15991 And got this answer: Special thanks to "Aker"!

System.Diagnostics.Process wsusou = new Process();
            wsusou.StartInfo.FileName = "cmd.exe";
            wsusou.StartInfo.Arguments = @"/k C:\Users\me\Desktop\trunk-r664\trunk\ExtractDownloadLinks-all.cmd"; // replace "/k" with "/c", if cmd should auto-close
            wsusou.StartInfo.WorkingDirectory = @"C:\Users\me\Desktop\trunk-r664\trunk";
            wsusou.Start();
            while (wsusou.HasExited == false)
            {
                System.Threading.Thread.Sleep(100);
            }
            wsusou.Dispose();